<html>
<head><meta charset="utf-8"><title>refactoring rustc predicates, a MCP · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html">refactoring rustc predicates, a MCP</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196304671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196304671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196304671">(May 05 2020 at 13:07)</a>:</h4>
<p>FYI, I filed a compiler-team MCP for refactoring rustc predicates. Discussion thread is in <a class="stream-topic" data-stream-id="233931" href="/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/intern.20predicates.2C.20introduce.20forall.2Fimplie.20compiler-team.23285">#t-compiler/major changes &gt; intern predicates, introduce forall/implie compiler-team#285</a></p>



<a name="196343166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196343166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196343166">(May 05 2020 at 17:59)</a>:</h4>
<p>This is tempting now that I have <em>some</em> experience hacking on rustc</p>



<a name="196878265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878265">(May 08 2020 at 10:19)</a>:</h4>
<p>So <span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> -- the branch is <a href="https://github.com/nikomatsakis/rust/tree/predicate-goal-2" title="https://github.com/nikomatsakis/rust/tree/predicate-goal-2">nikomatsakis/predicate-goal-2</a></p>



<a name="196878274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878274">(May 08 2020 at 10:19)</a>:</h4>
<p>I'm working so far on the "intern all predicates" step</p>



<a name="196878292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878292">(May 08 2020 at 10:19)</a>:</h4>
<p>which is also a step towards "extracting a shared ty library for rustc/chalk/rust-analyzer" so <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="196878345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878345">(May 08 2020 at 10:20)</a>:</h4>
<p>my first attempt (the <code>predicate-goal</code> branch) tried to do too much at once and I just about died</p>



<a name="196878402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878402">(May 08 2020 at 10:20)</a>:</h4>
<p>but I've now done three steps</p>
<ul>
<li>rename <code>Predicate</code> to <code>PredicateKind</code>, introduce alias</li>
<li>make <code>to_predicate</code> take a <code>tcx</code> argument </li>
<li>introduce newtype'd <code>Predicate&lt;'tcx&gt;</code></li>
</ul>



<a name="196878412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878412">(May 08 2020 at 10:21)</a>:</h4>
<p>at this point most of the hard work, I think, is done</p>



<a name="196878427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878427">(May 08 2020 at 10:21)</a>:</h4>
<p>the next step is to change the (existing) <code>mk_predicate</code> method to actually do interning</p>



<a name="196878442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878442">(May 08 2020 at 10:21)</a>:</h4>
<p>at that point, I think it's a PR worth posting,</p>



<a name="196878447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878447">(May 08 2020 at 10:21)</a>:</h4>
<p>and I guess we get to the interesting stuff :)</p>



<a name="196878728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878728">(May 08 2020 at 10:24)</a>:</h4>
<p>I guess i'll try to take that final step</p>



<a name="196878744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878744">(May 08 2020 at 10:25)</a>:</h4>
<p>and then we can discuss the remainder?</p>



<a name="196878763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878763">(May 08 2020 at 10:25)</a>:</h4>
<p>at least I still have some time this morning</p>



<a name="196878874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878874">(May 08 2020 at 10:26)</a>:</h4>
<p>You can do that, I would prefer you to review <a href="https://github.com/rust-lang/rust/pull/71973" title="https://github.com/rust-lang/rust/pull/71973">https://github.com/rust-lang/rust/pull/71973</a> while I finish your branch here though <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="196878992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196878992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196878992">(May 08 2020 at 10:28)</a>:</h4>
<p>lol that's..not a bad idea :)</p>



<a name="196879001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879001">(May 08 2020 at 10:28)</a>:</h4>
<p>that is on my morning agenda.. :)</p>



<a name="196879010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879010">(May 08 2020 at 10:28)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> I just remembered sometihng</p>



<a name="196879034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879034">(May 08 2020 at 10:28)</a>:</h4>
<p>well, it's minor enough, but one other bit of work is</p>



<a name="196879048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879048">(May 08 2020 at 10:28)</a>:</h4>
<p>currently I have a <code>Predicate</code> struct with a <code>kind()</code> method that returns <code>PredicateKind</code></p>



<a name="196879064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879064">(May 08 2020 at 10:29)</a>:</h4>
<p>I guess that to be "most like" chalk, it should return a <code>&amp;PredicateKind</code></p>



<a name="196879072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879072">(May 08 2020 at 10:29)</a>:</h4>
<p>though I might wait on doing that</p>



<a name="196879099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879099">(May 08 2020 at 10:29)</a>:</h4>
<p>it'll be a mildly annoying change because it'll cause the various matches to yield <code>&amp;DefId</code> instead of <code>DefId</code></p>



<a name="196879117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879117">(May 08 2020 at 10:29)</a>:</h4>
<p>/me grumbles that we don't have an ergonomic fix for that yet</p>



<a name="196879197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879197">(May 08 2020 at 10:30)</a>:</h4>
<p>meh, let's hold off on that, I think that's more logically part of another PR series...</p>



<a name="196879204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879204">(May 08 2020 at 10:30)</a>:</h4>
<blockquote>
<p>I guess that to be "most like" chalk, it should return a &amp;PredicateKind</p>
</blockquote>
<p>won't we have to do this anyways once <code>PredicateKind</code> is interned?</p>



<a name="196879237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879237">(May 08 2020 at 10:30)</a>:</h4>
<p>no, because it's also <code>Copy</code></p>



<a name="196879246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879246">(May 08 2020 at 10:31)</a>:</h4>
<p>ok, I just pushed a WIP commit</p>



<a name="196879263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879263">(May 08 2020 at 10:31)</a>:</h4>
<p>and now I see you need a few annoying impls, like a Lift impl and the like</p>



<a name="196879270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879270">(May 08 2020 at 10:31)</a>:</h4>
<p>I'll hand off that part to you :P</p>



<a name="196879276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879276">(May 08 2020 at 10:31)</a>:</h4>
<p>actually I need to go and prep breakfast anyway</p>



<a name="196879296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879296">(May 08 2020 at 10:31)</a>:</h4>
<p>but I do plan to review <a href="https://github.com/rust-lang/rust/issues/71973" title="https://github.com/rust-lang/rust/issues/71973">#71973</a>!</p>



<a name="196879310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879310">(May 08 2020 at 10:31)</a>:</h4>
<p>(though my morning coffee time is usually reserved for a bit of hacking or reading or something ;)</p>



<a name="196879508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879508">(May 08 2020 at 10:34)</a>:</h4>
<blockquote>
<p>no, because it's also Copy</p>
</blockquote>
<p>We still want to to use <code>&amp;T</code> for the quicker equality checks afaict <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> probably can do that later though</p>



<a name="196879861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879861">(May 08 2020 at 10:39)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> to be clear, 'm happy to change it to return <code>&amp;PredicateKind</code></p>



<a name="196879875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/196879875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#196879875">(May 08 2020 at 10:39)</a>:</h4>
<p>I would still do it in a separate commit, but I'd be happy to have it done</p>



<a name="197002461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197002461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197002461">(May 09 2020 at 17:26)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> are you using <code>cargo fmt</code> directly instead of <code>x.py fmt</code>?</p>



<a name="197003187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197003187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197003187">(May 09 2020 at 17:42)</a>:</h4>
<p>Was there a reason for choosing <code>struct Predicate { kind: &amp;'tcx PredicateKind&lt;'tcx&gt; }</code> over <code>type Predicate&lt;'tcx&gt; = &amp;'tcx PredicateKind&lt;'tcx&gt;</code>? (edit: ah, changing it to a type alias requires us to manually impl <code>TypeFoldable</code> (and probably some other stuff))</p>



<a name="197003322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197003322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197003322">(May 09 2020 at 17:46)</a>:</h4>
<p>Fixed the missing impl and opened a draft PR <a href="https://github.com/rust-lang/rust/pull/72055" title="https://github.com/rust-lang/rust/pull/72055">https://github.com/rust-lang/rust/pull/72055</a></p>



<a name="197182695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182695">(May 11 2020 at 18:02)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> I think rust-analylzer was running rustfmt sometimes, I was expecting to do a <code>x.py fmt</code> at the end</p>



<a name="197182706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182706">(May 11 2020 at 18:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/197003187">said</a>:</p>
<blockquote>
<p>Was there a reason for choosing <code>struct Predicate { kind: &amp;'tcx PredicateKind&lt;'tcx&gt; }</code> over <code>type Predicate&lt;'tcx&gt; = &amp;'tcx PredicateKind&lt;'tcx&gt;</code>? (edit: ah, changing it to a type alias requires us to manually impl <code>TypeFoldable</code> (and probably some other stuff))</p>
</blockquote>
<p>Yes</p>



<a name="197182714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182714">(May 11 2020 at 18:02)</a>:</h4>
<p>Two reasons</p>



<a name="197182725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182725">(May 11 2020 at 18:02)</a>:</h4>
<p>I started with the type alias, but</p>



<a name="197182747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182747">(May 11 2020 at 18:03)</a>:</h4>
<p>when you invoke <code>pred.fold_with(&amp;mut folder)</code>, the method resolution algorithm would pick the wrong type</p>



<a name="197182777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182777">(May 11 2020 at 18:03)</a>:</h4>
<p>that was the first reason.</p>



<a name="197182804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182804">(May 11 2020 at 18:03)</a>:</h4>
<p>Also see my WIP comment on the PR:</p>
<blockquote>
<p>IMO we should also replace Predicate with type Predicate&lt;'tcx&gt; = &amp;'tcx PredicateKind&lt;'tcx&gt; (edit: in this PR), even if we have to manually implement TypeFoldable and friends in this case.</p>
</blockquote>
<p>Let's not do that :laugh: It's quite dangerous as we can't make the constructor of <code>PredicateKind</code> private, which probably will cause some strange errors where we compare their pointers for equality</p>



<a name="197182813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182813">(May 11 2020 at 18:03)</a>:</h4>
<p>the second reason was that I realized that this structure matched the chalk structure more closely that I'm hoping to move the compiler towards anyway</p>



<a name="197182880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182880">(May 11 2020 at 18:04)</a>:</h4>
<p>so actually it's what I should've done in the first place</p>



<a name="197182901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182901">(May 11 2020 at 18:04)</a>:</h4>
<p>yes, and that was the third reason</p>



<a name="197182910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182910">(May 11 2020 at 18:04)</a>:</h4>
<p>(comparing pointers for equality)</p>



<a name="197182956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197182956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197182956">(May 11 2020 at 18:04)</a>:</h4>
<p>tl;dr I think the <code>Predicate&lt;'tcx&gt;</code> struct is what we want, but it's good to note the reasons</p>



<a name="197183032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183032">(May 11 2020 at 18:05)</a>:</h4>
<p>I just implemented a third option, which solves 1 and 3, but sadly not 2</p>



<a name="197183118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183118">(May 11 2020 at 18:06)</a>:</h4>
<p>I changed <code>Predicate</code> back to <code>kind: PredicateKind</code> and interned <code>Predicate</code> itself.</p>



<a name="197183197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183197">(May 11 2020 at 18:07)</a>:</h4>
<p>I pushed this on github, but if you think that it's better to stay with <code>Predicate { kind: &amp;'tcx PredicateKind&lt;'Tcx&gt; }</code> I can revert that last commit.</p>



<a name="197183201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183201">(May 11 2020 at 18:07)</a>:</h4>
<p>I still think <code>Predicate&lt;'tcx&gt;</code> as a newtype struct is just correct</p>



<a name="197183242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183242">(May 11 2020 at 18:07)</a>:</h4>
<p>but I can check what you pushed :)</p>



<a name="197183246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183246">(May 11 2020 at 18:07)</a>:</h4>
<p>cause I don't quite understand</p>



<a name="197183385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183385">(May 11 2020 at 18:08)</a>:</h4>
<p>What is the advantage to using <code>&amp;'tcx Predicate&lt;'tcx&gt;</code> over <code>Predicate&lt;'tcx&gt;</code>? It seems less ergonomic (longer type name) and more expensive (more interning)</p>



<a name="197183446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183446">(May 11 2020 at 18:09)</a>:</h4>
<p>It's the same amount of interning, as predicate now contains <code>PredicateKind</code> directly</p>



<a name="197183456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183456">(May 11 2020 at 18:09)</a>:</h4>
<p>Ah, ok, I see</p>



<a name="197183470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183470">(May 11 2020 at 18:09)</a>:</h4>
<p>Still seems like more typing though</p>



<a name="197183488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183488">(May 11 2020 at 18:09)</a>:</h4>
<p>also less consistent</p>



<a name="197183507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183507">(May 11 2020 at 18:09)</a>:</h4>
<p>e.g., we usually use <code>ty::Region&lt;'tcx&gt;</code> and <code>Ty&lt;'tcx&gt;</code>, etc</p>



<a name="197183509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183509">(May 11 2020 at 18:10)</a>:</h4>
<p><code>Eq</code> now has one less dereference <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> biggest reason tbh</p>



<a name="197183593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183593">(May 11 2020 at 18:10)</a>:</h4>
<p>heh ok :)</p>



<a name="197183632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183632">(May 11 2020 at 18:10)</a>:</h4>
<p>I doubt that's relevant if we inline it though <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="197183825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183825">(May 11 2020 at 18:12)</a>:</h4>
<p>The same for <code>Fold</code> etc, I don't know if there is an actual perf advantage though.</p>



<a name="197183843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183843">(May 11 2020 at 18:12)</a>:</h4>
<p>Yeah, I doubt it</p>



<a name="197183874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183874">(May 11 2020 at 18:12)</a>:</h4>
<p>I guess I'd go with the struct, because it aligns with the chalk library</p>



<a name="197183957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183957">(May 11 2020 at 18:13)</a>:</h4>
<p>I don't really think it's going to be a big difference at runtime, though it's true we're ultimately passing pointers-to-pointers</p>



<a name="197183983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197183983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197183983">(May 11 2020 at 18:13)</a>:</h4>
<p>(conceivably we could address this by making some of those traits pass by value, in the future;</p>



<a name="197184040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197184040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197184040">(May 11 2020 at 18:14)</a>:</h4>
<p>as rustc has moved more and more towards interning and away from ref counting, that makes sense,</p>



<a name="197184056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197184056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197184056">(May 11 2020 at 18:14)</a>:</h4>
<p>and I think that rust-analyzer is similar, at least if it's using the salsa interning mechanism)</p>



<a name="197184292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197184292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197184292">(May 11 2020 at 18:16)</a>:</h4>
<p>Ok, the PR is currently blocked on <a href="https://github.com/rust-lang/rust/pull/72060">https://github.com/rust-lang/rust/pull/72060</a>.<br>
 I don't want to add <code>// ignore-tidy-filelength</code>  just to remove it the next day <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> </p>
<p>Will revert the last change and update most methods to take <code>Predicate</code> by value.</p>



<a name="197184306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197184306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197184306">(May 11 2020 at 18:16)</a>:</h4>
<p>Do you know who might want to review this PR?</p>



<a name="197184837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/197184837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#197184837">(May 11 2020 at 18:21)</a>:</h4>
<p>either me or <span class="user-mention" data-user-id="119009">@eddyb</span> -- perhaps them, given that I authored some share of the commits</p>



<a name="198416514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198416514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198416514">(May 22 2020 at 08:21)</a>:</h4>
<p>Now that <a href="https://github.com/rust-lang/rust/pull/72055">https://github.com/rust-lang/rust/pull/72055</a> is merged, the next step would be</p>
<blockquote>
<p>Introduce forall:</p>
<div class="codehilite"><pre><span></span><code>* Introduce `forall` predicate goals and integrate into the fulfillment context

  * hmm -- this may require finishing up the universe integration work, which is semi-blocked

* Remove the mandatory binder on trait predicates and other predicates and use forall goals
</code></pre></div>


</blockquote>
<p>What is a good place to learn more about the universe integration work?</p>



<a name="198429374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198429374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198429374">(May 22 2020 at 11:08)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> will drop some notes here later this morning</p>



<a name="198429390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198429390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198429390">(May 22 2020 at 11:08)</a>:</h4>
<p>though the draft MCP I just described in <a class="stream-topic" data-stream-id="144729" href="/#narrow/stream/144729-wg-traits/topic/moving.20the.20leak.20check.20to.20evaluation">#wg-traits &gt; moving the leak check to evaluation</a> gives some abckground, I think not all that directly relevant here</p>



<a name="198471212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471212">(May 22 2020 at 17:36)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> before we dig too much into that stuff above, let's talk here</p>



<a name="198471317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471317">(May 22 2020 at 17:37)</a>:</h4>
<p>so there are basically two kinds of predicates to add</p>



<a name="198471321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471321">(May 22 2020 at 17:37)</a>:</h4>
<p>ForAll and Implies</p>



<a name="198471344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471344">(May 22 2020 at 17:37)</a>:</h4>
<p>I'm not sure what's the best order, but the machinery to handle a ForAll already exists</p>



<a name="198471376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471376">(May 22 2020 at 17:38)</a>:</h4>
<p>so I guess that's a good place to start</p>



<a name="198471461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471461">(May 22 2020 at 17:38)</a>:</h4>
<p>I forget a bit what I wrote in the MCP, but thinking about it now, there's probably .. hmm .. a few steps</p>



<a name="198471495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471495">(May 22 2020 at 17:38)</a>:</h4>
<p>we can certainly add a <code>ForAll(Binder&lt;Predicate&lt;'tcx&gt;&gt;)</code> variant and plumb the code for it</p>



<a name="198471500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471500">(May 22 2020 at 17:38)</a>:</h4>
<p>the problem will be using it for anything ;)</p>



<a name="198471570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471570">(May 22 2020 at 17:39)</a>:</h4>
<p>I guess the next step would be that whenever you have <code>for&lt;'a&gt; T: Trait&lt;'a&gt;</code> or something, we translate that into a <code>ForAll</code> predciate --</p>



<a name="198471600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471600">(May 22 2020 at 17:39)</a>:</h4>
<p>right now, the ForAll is kind of banked into every <em>other</em> sort of predicate</p>



<a name="198471614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471614">(May 22 2020 at 17:39)</a>:</h4>
<p>eventually I would want to get to something like</p>



<a name="198471755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471755">(May 22 2020 at 17:40)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">enum</span> <span class="nc">Predicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Trait</span><span class="p">(</span><span class="n">TraitPredicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">Constness</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">RegionOutlives</span><span class="p">(</span><span class="n">RegionOutlivesPredicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">TypeOutlives</span><span class="p">(</span><span class="n">TypeOutlivesPredicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="o">..</span><span class="p">.,</span><span class="w"></span>
<span class="w">    </span><span class="n">ForAll</span><span class="p">(</span><span class="n">Binder</span><span class="o">&lt;</span><span class="n">Predicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;&gt;</span><span class="p">),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="198471824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471824">(May 22 2020 at 17:41)</a>:</h4>
<p>instead of what we have today</p>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">enum</span> <span class="nc">Predicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Trait</span><span class="p">(</span><span class="n">PolyTraitPredicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">Constness</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">RegionOutlives</span><span class="p">(</span><span class="n">PolyRegionOutlivesPredicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">TypeOutlives</span><span class="p">(</span><span class="n">PolyTypeOutlivesPredicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="o">..</span><span class="p">.,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="198471833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471833">(May 22 2020 at 17:41)</a>:</h4>
<p>I think I've implemented this like 2 or 3 times and each time it made the code much nicer ;)</p>



<a name="198471862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471862">(May 22 2020 at 17:41)</a>:</h4>
<p>because it means that you "concentrate" the logic  of how to do a for-all in one place</p>



<a name="198471880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471880">(May 22 2020 at 17:41)</a>:</h4>
<p>I'm trying to think the best steps to do it in</p>



<a name="198471900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198471900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198471900">(May 22 2020 at 17:41)</a>:</h4>
<p>probably adding in ForAll, then trying to use it, then trying to remove the Poly from everywhere else</p>



<a name="198472004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198472004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198472004">(May 22 2020 at 17:42)</a>:</h4>
<p>I sort of remember the code that generates e.g. the <code>PolyTraitPredicate</code> is a bit messy, but I guess you can always just change to generate a <code>Predicate::ForAll</code> in a fairly simple way</p>



<a name="198472059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198472059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198472059">(May 22 2020 at 17:42)</a>:</h4>
<p>but it might be easier to remove the <code>Poly</code> and add the<code>ForAll</code> at the same time, since it doesn't change anything about the debruijn indices</p>



<a name="198472601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198472601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198472601">(May 22 2020 at 17:47)</a>:</h4>
<p>Ok, I think I mostly understand what to do here at a high level <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="198472731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198472731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198472731">(May 22 2020 at 17:48)</a>:</h4>
<p>I think the change to add <code>ForAll</code> would be relatively easy, probably all happens in <a href="http://fulfill.rs">fulfill.rs</a></p>



<a name="198486278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198486278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198486278">(May 22 2020 at 19:43)</a>:</h4>
<p>nit: I visually prefer  <code>Forall</code> over <code>ForAll</code> <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> You probably already use <code>Forall</code> in chalk if I understand this correctly?</p>



<a name="198486334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198486334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198486334">(May 22 2020 at 19:43)</a>:</h4>
<p>I have no idea :)</p>



<a name="198486385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198486385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198486385">(May 22 2020 at 19:44)</a>:</h4>
<p>whichever is fine for me</p>



<a name="198486532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198486532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198486532">(May 22 2020 at 19:45)</a>:</h4>
<p>chalk is using <code>ForAll</code>, so let's just use that.</p>



<a name="198551403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198551403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198551403">(May 23 2020 at 20:47)</a>:</h4>
<p>I often have to go from <code>Binder(Predicate)</code> to <code>Predicate(Binder(data))</code> and wasn't able to come up with a good approach.</p>
<p>While something like the following works, this seems far worse than the current solution without <code>ForAll</code> <span aria-label="oh no" class="emoji emoji-1f615" role="img" title="oh no">:oh_no:</span></p>
<div class="codehilite"><pre><span></span><code><span class="k">match</span><span class="w"> </span><span class="n">pred</span><span class="p">.</span><span class="n">skip_binder</span><span class="p">().</span><span class="n">kind</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">Trait</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Binder</span>::<span class="n">bind</span><span class="p">(</span><span class="n">t</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="c1">// ...</span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ...</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="198812596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812596">(May 26 2020 at 19:50)</a>:</h4>
<p>Hmm</p>



<a name="198812628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812628">(May 26 2020 at 19:50)</a>:</h4>
<p>I don't fully understand :)</p>



<a name="198812655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812655">(May 26 2020 at 19:50)</a>:</h4>
<p>I guess I expect you to go from <code>Binder(Predicate)</code> to <code>Predicate::ForAll(Binder(Predicate))</code></p>



<a name="198812665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812665">(May 26 2020 at 19:50)</a>:</h4>
<p>i.e., just add a layer</p>



<a name="198812715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812715">(May 26 2020 at 19:51)</a>:</h4>
<p>We currently have <code>Predicate(Binder(data))</code>, not <code>Binder(Predicate(data))</code>.</p>



<a name="198812859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812859">(May 26 2020 at 19:52)</a>:</h4>
<p>We want to change this to <code>Predicate::ForAll(Binder(Predicate(data)))</code></p>



<a name="198812917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812917">(May 26 2020 at 19:52)</a>:</h4>
<p>So to once again correctly bind data, I currently use the above pattern</p>



<a name="198812987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198812987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198812987">(May 26 2020 at 19:53)</a>:</h4>
<p>i.e. the above snippet is inside of <code>PredicateKind::ForAll</code></p>



<a name="198817397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198817397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198817397">(May 26 2020 at 20:28)</a>:</h4>
<p>it seems like you may be making the change too "late" somehow</p>



<a name="198817409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198817409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198817409">(May 26 2020 at 20:28)</a>:</h4>
<p>might help to see the branch</p>



<a name="198817886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/198817886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#198817886">(May 26 2020 at 20:32)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/compare/master...lcnr:forall-predicate#diff-a93d21c5310d929ca75aa69ba2d970bb">https://github.com/rust-lang/rust/compare/master...lcnr:forall-predicate#diff-a93d21c5310d929ca75aa69ba2d970bb</a></p>
<p>this is still somewhat of a mess <em>edit: and subst_super_trait` is actually incorrect</em> <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="199086171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199086171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199086171">(May 28 2020 at 21:01)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span>  this is my current definition of <code>PredicateKind</code>: <a href="https://github.com/lcnr/rust/blob/a70ec3a5a1c88a7870a6cd4c8403a6bd6d0a395d/src/librustc_middle/ty/mod.rs#L1051-L1096">https://github.com/lcnr/rust/blob/a70ec3a5a1c88a7870a6cd4c8403a6bd6d0a395d/src/librustc_middle/ty/mod.rs#L1051-L1096</a></p>



<a name="199599502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199599502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199599502">(Jun 03 2020 at 09:50)</a>:</h4>
<p>To be more specific, I currently do this: (<a href="https://github.com/rust-lang/rust/compare/master...lcnr:forall-predicate#diff-236fd1c050048463d34c039bc71b21acR74-R434">https://github.com/rust-lang/rust/compare/master...lcnr:forall-predicate#diff-236fd1c050048463d34c039bc71b21acR74-R434</a>) if the binder can be ignored. If the binder were not irrelevant here, I don't quite know how to best solve this?</p>



<a name="199599675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199599675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199599675">(Jun 03 2020 at 09:52)</a>:</h4>
<p>I could either always bind the relevant elements, without caring about <code>forall</code>, which seems wierd:</p>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">predicate</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">predicate</span><span class="p">.</span><span class="n">kind</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="c1">// It&#39;s ok to skip binders here, because wf code is prepared for it</span>
<span class="w">        </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">ForAll</span><span class="p">(</span><span class="n">binder</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">binder</span><span class="p">.</span><span class="n">skip_binder</span><span class="p">().</span><span class="n">kind</span><span class="p">(),</span><span class="w"></span>
<span class="w">        </span><span class="n">pred</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">pred</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>

<span class="w">    </span><span class="k">match</span><span class="w"> </span><span class="n">predicate</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">ForAll</span><span class="p">(</span><span class="o">..</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">bug</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;unexpected predicate: {:?}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">predicate</span><span class="p">),</span><span class="w"></span>
<span class="w">        </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">Trait</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Binder</span>::<span class="n">bind</span><span class="p">(</span><span class="n">t</span><span class="p">);</span><span class="w"></span>
<span class="w">            </span><span class="c1">// ...</span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="199599873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199599873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199599873">(Jun 03 2020 at 09:54)</a>:</h4>
<p>Or differentiate between <code>forall</code> and other predicates:</p>
<div class="codehilite"><pre><span></span><code><span class="k">match</span><span class="w"> </span><span class="n">predicate</span><span class="p">.</span><span class="n">kind</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">ForAll</span><span class="p">(</span><span class="n">binder</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">predicate</span><span class="p">.</span><span class="n">skip_binder</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">ForAll</span><span class="p">(</span><span class="o">..</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">bug</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;unexpected predicate: {:?}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">predicate</span><span class="p">),</span><span class="w"></span>
<span class="w">        </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">Trait</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Binder</span>::<span class="n">bind</span><span class="p">(</span><span class="n">t</span><span class="p">);</span><span class="w"> </span><span class="c1">// &lt;------------ my problem</span>
<span class="w">            </span><span class="c1">// ...</span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">},</span><span class="w"></span>
<span class="w">    </span><span class="n">ty</span>::<span class="n">PredicateKind</span>::<span class="n">Trait</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="c1">// ...</span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ...</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="199600018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600018">(Jun 03 2020 at 09:56)</a>:</h4>
<p>In all these cases I have to actively worry about rebinding inside of <code>ForAll</code>, which feels quite dangerous, as I can easily miss this and I can't think of a way to encapsulate this logic to prevent misuse.</p>



<a name="199600076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600076">(Jun 03 2020 at 09:57)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> ok thanks for the details, I meant to get back to you on that, and I remember not being quite sure what I was looking at :)</p>



<a name="199600085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600085">(Jun 03 2020 at 09:57)</a>:</h4>
<p>I"m skimming over some of the diffs now</p>



<a name="199600090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600090">(Jun 03 2020 at 09:57)</a>:</h4>
<p>i.e. how can I go from <code>Binder(Predicate::Trait(TraitRef, ...)</code> to <code>Predicate::Trait(Binder(TraitRef), ...)</code>.</p>



<a name="199600236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600236">(Jun 03 2020 at 09:59)</a>:</h4>
<p>although those links don't really point me at a specific diff</p>



<a name="199600251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600251">(Jun 03 2020 at 09:59)</a>:</h4>
<p>I still don't quite understand why the question comes up</p>



<a name="199600371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600371">(Jun 03 2020 at 10:00)</a>:</h4>
<p>Let's see where exactly it is either unclear or I am missing something:</p>



<a name="199600400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600400">(Jun 03 2020 at 10:00)</a>:</h4>
<ol>
<li>we currently have <code>PredicateKind::Variant(Binder&lt;Data&gt;)</code></li>
</ol>



<a name="199600440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600440">(Jun 03 2020 at 10:01)</a>:</h4>
<ol start="2">
<li>we want to go to <code>PredicateKind::ForAll(Binder&lt;Predicate&gt;)</code></li>
</ol>



<a name="199600497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600497">(Jun 03 2020 at 10:01)</a>:</h4>
<p>2.1. at the same time, other predicates don't need a binder anymore, so I change them to <code>PredicateKind::Variant(Data)</code>, as the <code>Binder</code> is now part of <code>ForAll</code>.</p>



<a name="199600617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600617">(Jun 03 2020 at 10:03)</a>:</h4>
<p>So something like <code>for&lt;'a&gt; T: Trait&lt;'a&gt;</code> is currently represented as <code>PredicateKind::Trait(Binder(TraitPredicate[T: Trait&lt;'??&gt;]))</code></p>



<a name="199600768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600768">(Jun 03 2020 at 10:04)</a>:</h4>
<p>My PR wants to change this to <code>PredicateKind::ForAll(Binder(PredicateKind::Trait(TraitPredicate)))</code></p>



<a name="199600915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600915">(Jun 03 2020 at 10:06)</a>:</h4>
<p>so far seems right (I'm skimming diffs btw)</p>



<a name="199600981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199600981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199600981">(Jun 03 2020 at 10:07)</a>:</h4>
<p>When I now want to deal with this Predicate, I have to match on the internal predicate (here <code>PredicateKind::Trait</code>) for which I have to skip<br>
the <code>Binder</code> using something like <code>skip_binder</code> or <code>match_bound</code>.</p>



<a name="199601207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601207">(Jun 03 2020 at 10:10)</a>:</h4>
<p>Inside of a <code>ForAll</code>, we should not be able to accidentally use the <code>TraitPredicate</code> directly, as this can easily lead us to forget the <code>Binder</code></p>



<a name="199601239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601239">(Jun 03 2020 at 10:10)</a>:</h4>
<p>So, this part seems .. sort of wrong. I may be out of date, but usually that's indeed now how it should work.</p>



<a name="199601258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601258">(Jun 03 2020 at 10:10)</a>:</h4>
<p>I think this may be an artifact of the code having been built around Predicates having binders so deeply ingrained</p>



<a name="199601279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601279">(Jun 03 2020 at 10:11)</a>:</h4>
<p>Versus being able to separate out "Forall" as one orthogonal concern that the rest of the code does't have to look at</p>



<a name="199601289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601289">(Jun 03 2020 at 10:11)</a>:</h4>
<p>I'm starting to see a few diffs that look a bit suspicious</p>



<a name="199601445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601445">(Jun 03 2020 at 10:13)</a>:</h4>
<p>(that said, it <em>may</em> be somewhat hard to separate in some cases)</p>



<a name="199601470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601470">(Jun 03 2020 at 10:13)</a>:</h4>
<p>I wonder if I can find my old branches, too...</p>



<a name="199601697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601697">(Jun 03 2020 at 10:16)</a>:</h4>
<p>as an example, I suppose, this diff from traits/wf.rs</p>
<div class="codehilite"><pre><span></span><code><span class="gd">-    // (*) ok to skip binders, because wf code is prepared for it</span>
<span class="gd">-    match predicate.kind() {</span>
<span class="gi">+    let predicate = match predicate.kind() {</span>
<span class="gi">+        // It&#39;s ok to skip binders here, because wf code is prepared for it</span>
<span class="gi">+        ty::PredicateKind::ForAll(binder) =&gt; binder.skip_binder().kind(),</span>
<span class="gi">+        pred =&gt; pred,</span>
<span class="gi">+    };</span>
<span class="gi">+</span>
<span class="gi">+    match predicate {</span>
<span class="gi">+        ty::PredicateKind::ForAll(..) =&gt; bug!(&quot;unexpected predicate: {:?}&quot;, predicate),</span>
</code></pre></div>


<p>doesn't seem right. I think what we would want is that <code>ForAll</code> kind of "maps" so that you recursively produce predicates from the content and then wrap those predicates in a binder. This is awkward though since we don't have a <code>Predicate::All(..)</code>. i.e., I guess that to have the structure I am imagining, you would want to be returning a single predicate.</p>



<a name="199601741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601741">(Jun 03 2020 at 10:17)</a>:</h4>
<p>what I do remember is that the trait selection code and other bits of code got nicer after this change because we no longer had so many parts of the code responsible for thinking about binders</p>



<a name="199601867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601867">(Jun 03 2020 at 10:19)</a>:</h4>
<p>but I can't find an actual branch yet with this change:)</p>



<a name="199601899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199601899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199601899">(Jun 03 2020 at 10:19)</a>:</h4>
<p>and maybe I never completed it or something :)</p>



<a name="199602001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199602001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199602001">(Jun 03 2020 at 10:20)</a>:</h4>
<p>ok, found it, or found some branches, chalkify-universe-wip-predicate-poly -- there are a bunch with similar names and of course I no longer remember their relationship to one another</p>



<a name="199602060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199602060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199602060">(Jun 03 2020 at 10:21)</a>:</h4>
<p>egads, 3 years ago...</p>



<a name="199602311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199602311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199602311">(Jun 03 2020 at 10:25)</a>:</h4>
<p>I see I did some refactoring of select/project e.g. in commit d3c074e2aee ... anyway, I have to run now, but I'll try to spend a bit more time digging in this morning.</p>



<a name="199602325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199602325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199602325">(Jun 03 2020 at 10:25)</a>:</h4>
<p>Probably there are some bits of refactoring we may want to do first</p>



<a name="199602381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199602381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199602381">(Jun 03 2020 at 10:26)</a>:</h4>
<p>as another example, in that branch I refactored trait selection in commit d3c074e2aee to isolate out the places that had to deal with foralls better</p>



<a name="199602388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199602388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199602388">(Jun 03 2020 at 10:26)</a>:</h4>
<p>but I'm also wondering whether -- instead of starting with <code>Predicate::ForAll</code>, we want to look at <code>Predicate::Implies</code></p>



<a name="199602984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199602984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199602984">(Jun 03 2020 at 10:34)</a>:</h4>
<p>Let's see how much I can improve my own understanding by looking at this branch, I feel like I don't yet fully get the "big picture" here.</p>



<a name="199778911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199778911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199778911">(Jun 04 2020 at 17:09)</a>:</h4>
<p>Will go ahead and start by bubbling poly predicates upwards, which probably makes it easier to handle the change to forall.</p>



<a name="199814556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199814556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199814556">(Jun 04 2020 at 22:06)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> sorry I didn't have time to spend more time on this :( :(</p>



<a name="199815111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199815111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199815111">(Jun 04 2020 at 22:12)</a>:</h4>
<p><span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span></p>



<a name="199815316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199815316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199815316">(Jun 04 2020 at 22:14)</a>:</h4>
<p>I wasn't able to spend too much time on this myself today, but I think a more correct way to handle forall predicates is to deal with the "forall part" separately and then use <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.replace_bound_vars_with_placeholders">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.replace_bound_vars_with_placeholders</a> on the inner predicate and check that one without having to care about escaping bound vars</p>



<a name="199815392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199815392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199815392">(Jun 04 2020 at 22:15)</a>:</h4>
<p>Which seems closer to what you did in chalkify-universe-wip-predicate-poly</p>



<a name="199815546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199815546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199815546">(Jun 04 2020 at 22:16)</a>:</h4>
<p>This solves my problem of having to constantly having to rebind binders and allow us to better separate concerns.</p>



<a name="199815576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199815576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199815576">(Jun 04 2020 at 22:16)</a>:</h4>
<p>is this close to what you had in mind?</p>



<a name="199924228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924228">(Jun 05 2020 at 19:37)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> maybe :)</p>



<a name="199924245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924245">(Jun 05 2020 at 19:37)</a>:</h4>
<p>well</p>



<a name="199924246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924246">(Jun 05 2020 at 19:38)</a>:</h4>
<p>yes</p>



<a name="199924291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924291">(Jun 05 2020 at 19:38)</a>:</h4>
<p>that sounds exactly like what I was thinking of</p>



<a name="199924338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924338">(Jun 05 2020 at 19:38)</a>:</h4>
<p>intuitively, we should usually be "moving downwards", if that makes sense, and convering bound things into placeholders</p>



<a name="199924354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924354">(Jun 05 2020 at 19:38)</a>:</h4>
<p>which reminds me, I have to rebase over your PR that breaks up <a href="http://select.rs">select.rs</a> :)</p>



<a name="199924372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924372">(Jun 05 2020 at 19:38)</a>:</h4>
<p>the most annoying kind of rebase, I wish git or some magic tool would handle it better</p>



<a name="199924426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924426">(Jun 05 2020 at 19:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/199924354">said</a>:</p>
<blockquote>
<p>which reminds me, I have to rebase over your PR that breaks up <a href="http://select.rs">select.rs</a> :)</p>
</blockquote>
<p>Your leak check PR?</p>



<a name="199924579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924579">(Jun 05 2020 at 19:40)</a>:</h4>
<p>Not sure about what you mean with "moving downwards" here</p>



<a name="199924666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924666">(Jun 05 2020 at 19:41)</a>:</h4>
<p>Do you mean we should start with converting <code>PredicateKind::Trait(PolyTraitPredicate)</code> to <code>PredicateKind::Trait(TraitPredicate)</code> and then fix all locations until it compiles again?</p>



<a name="199924850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199924850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199924850">(Jun 05 2020 at 19:43)</a>:</h4>
<p>instead of "moving upwards" which in this case would then probably mean changing all locations using <code>PolyTraitPredicate</code> without actually caring about binders first, and propagating these changes upwards until we end up at <code>PredicateKind::Trait</code>?</p>



<a name="199964671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199964671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199964671">(Jun 06 2020 at 09:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> looking into how to correctly use <code>replace_bound_vars_with_placeholders</code>, can you explain to me why this use is sound?<br>
<a href="https://github.com/rust-lang/rust/blob/826cb062a659f7b719a8a0ab1497a78229318aab/src/librustc_trait_selection/traits/select/confirmation.rs#L234">https://github.com/rust-lang/rust/blob/826cb062a659f7b719a8a0ab1497a78229318aab/src/librustc_trait_selection/traits/select/confirmation.rs#L234</a></p>
<p>At least to my understanding this seems like a somewhat sketchy way to remove the binder.</p>



<a name="199964748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199964748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199964748">(Jun 06 2020 at 09:08)</a>:</h4>
<p><code>replace_bound_vars_with_placeholders</code> should be able to change the substs of <code>poly_trait_ref</code> to contain a placeholder</p>



<a name="199964767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199964767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199964767">(Jun 06 2020 at 09:09)</a>:</h4>
<p>Which is then used in <code>impl_or_trait_obligations</code> and leaked from a snapshot due to <code>commit_unconditionally</code></p>



<a name="199964774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199964774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199964774">(Jun 06 2020 at 09:09)</a>:</h4>
<p>Which to my understanding must not happen</p>



<a name="199972441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199972441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199972441">(Jun 06 2020 at 12:22)</a>:</h4>
<p><code>TraitRef</code> has the following docs:</p>
<blockquote>
<p>Note that a TraitRef introduces a level of region binding, to account for higher-ranked trait bounds like T: for&lt;'a&gt; Foo&lt;&amp;'a U&gt; or higher-ranked object types.</p>
</blockquote>
<p>Is still still true? Afaik only <code>PolyTraitRef</code> actually introduces a binder</p>



<a name="199975865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/199975865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#199975865">(Jun 06 2020 at 13:50)</a>:</h4>
<p>It's not still true.</p>



<a name="200157780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200157780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200157780">(Jun 08 2020 at 21:23)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> so that line is an example of what I mean by "moving downwards" --</p>



<a name="200157891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200157891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200157891">(Jun 08 2020 at 21:24)</a>:</h4>
<p>basically I mean that trying to prove something about <code>for&lt;..&gt; X</code> should </p>
<ul>
<li>instantiate the bound variables with placeholders in some fresh universe</li>
<li>then create new things to prove that are in that context</li>
</ul>
<p>but not try to return some result up that can be used</p>



<a name="200157904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200157904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200157904">(Jun 08 2020 at 21:24)</a>:</h4>
<p>I think in the case of normalization there is a good example</p>



<a name="200157925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200157925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200157925">(Jun 08 2020 at 21:24)</a>:</h4>
<p>if you had <code>for&lt;'a&gt; { &lt;T as Foo&lt;'a&gt;&gt;::Bar = U }</code></p>



<a name="200157933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200157933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200157933">(Jun 08 2020 at 21:24)</a>:</h4>
<p>what we <em>don't</em> want to do is try to transform that to something like</p>



<a name="200157949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200157949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200157949">(Jun 08 2020 at 21:25)</a>:</h4>
<p><code>for&lt;'a&gt; { XXX = U }</code> where we figure out what <code>XXX</code> is by normalizing</p>



<a name="200158025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200158025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200158025">(Jun 08 2020 at 21:25)</a>:</h4>
<p>what we <em>do</em> want to do is to trigger a "subobligation" to prove <code>&lt;T as Foo&lt;'!a&gt;&gt;::Bar = U</code>, where <code>!a</code> is a placeholder</p>



<a name="200158085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200158085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200158085">(Jun 08 2020 at 21:26)</a>:</h4>
<p>placeholders are basically just universally bound variables</p>



<a name="200158196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200158196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200158196">(Jun 08 2020 at 21:26)</a>:</h4>
<p>so e.g. on <a href="https://github.com/rust-lang/rust/blob/826cb062a659f7b719a8a0ab1497a78229318aab/src/librustc_trait_selection/traits/select/confirmation.rs#L234">this line</a> we're saying that "we need to prove all the subobligations, instantiated with placeholders"</p>



<a name="200162505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200162505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200162505">(Jun 08 2020 at 22:15)</a>:</h4>
<p>I still don't quite get where placeholders are okay and where they are forbidden.</p>
<p>Reading your above explanation, I am now also less sure in my understanding of the difference between <code>Placeholder</code> and <code>Bound</code></p>



<a name="200162801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200162801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200162801">(Jun 08 2020 at 22:19)</a>:</h4>
<p>I think this confusion is mostly caused by the afaict outdated comment of <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.replace_bound_vars_with_placeholders">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.replace_bound_vars_with_placeholders</a>. I think you updating the dev-guide and the description of <code>replace_bound_vars_with_placeholders</code> will be really helpful here.</p>



<a name="200163128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200163128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200163128">(Jun 08 2020 at 22:23)</a>:</h4>
<p>Most relevant for this issue is the relation of <code>Placeholder</code>s inside of <code>Predicate</code>s.</p>



<a name="200163230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200163230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200163230">(Jun 08 2020 at 22:24)</a>:</h4>
<p>Let's say we have want to elaborate <code>for&lt;'a&gt; &amp;'a T: Bar</code> here</p>
<div class="codehilite"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Bar</span>: <span class="nc">Foo</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="k">for</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="o">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="n">T</span>: <span class="nc">Bar</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="200163326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200163326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200163326">(Jun 08 2020 at 22:25)</a>:</h4>
<p>Afaict we would go from <code>Forall(Binder(Trait[&amp;'a T: Bar]))</code> to <code>Trait[&amp;'!a T: Bar]</code> where <code>!a</code> is a placeholder</p>



<a name="200163400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200163400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200163400">(Jun 08 2020 at 22:26)</a>:</h4>
<p>Which we elaborate, resulting in <code>Trait[&amp;'!a T: Foo]</code></p>



<a name="200163450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200163450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200163450">(Jun 08 2020 at 22:27)</a>:</h4>
<p>Which we then want to turn back into <code>Forall(Binder(Trait[&amp;'a T: Foo]))</code></p>



<a name="200163651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200163651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200163651">(Jun 08 2020 at 22:29)</a>:</h4>
<p><code>Elaborator::elaborate</code> should be using <code>map_bound</code>, not creating placeholders.</p>



<a name="200164305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200164305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200164305">(Jun 08 2020 at 22:37)</a>:</h4>
<p>Though that also might not be so easy with arbitrary <code>PredicateKind::Forall</code> nesting.</p>



<a name="200164687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200164687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200164687">(Jun 08 2020 at 22:42)</a>:</h4>
<blockquote>
<p>Elaborator::elaborate should be using map_bound, not creating placeholders.</p>
</blockquote>
<p>I think I get why here, which is already progress <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> sleeping may help here, let's see if it's better tomorrow</p>



<a name="200188226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200188226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200188226">(Jun 09 2020 at 07:13)</a>:</h4>
<p>Something to consider here (if you haven't already) is making sure that you don't get into infinite loops from creating predicates with increasing numbers of unnecessary <code>ForAll</code> wrappers.</p>



<a name="200474654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200474654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200474654">(Jun 10 2020 at 20:51)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> how are you feeling about this? I'm having a hard time figuring out how to help out :)</p>



<a name="200475439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200475439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200475439">(Jun 10 2020 at 20:57)</a>:</h4>
<p>I have an exam next tuesday, so I can't really focus on this atm.</p>



<a name="200475449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200475449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200475449">(Jun 10 2020 at 20:57)</a>:</h4>
<p>I think it would be really helpful to update the doc comment for <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.replace_bound_vars_with_placeholders">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.replace_bound_vars_with_placeholders</a></p>



<a name="200475473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200475473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200475473">(Jun 10 2020 at 20:57)</a>:</h4>
<p>As this is probably a large part of what caused my confusion</p>



<a name="200475603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200475603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200475603">(Jun 10 2020 at 20:58)</a>:</h4>
<p>I also think that hrtb are somewhat complicated so it might just take some time until I fully understand how rustc deals with them</p>



<a name="200476184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200476184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200476184">(Jun 10 2020 at 21:02)</a>:</h4>
<p>is there a branch I can check out and play with?</p>



<a name="200476202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200476202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200476202">(Jun 10 2020 at 21:03)</a>:</h4>
<p>I think I've asked you before but I forget</p>



<a name="200477056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200477056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200477056">(Jun 10 2020 at 21:09)</a>:</h4>
<p>well, I pushed the current mess to <a href="https://github.com/lcnr/rust/tree/forall-predicate-wow">https://github.com/lcnr/rust/tree/forall-predicate-wow</a></p>



<a name="200477145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200477145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200477145">(Jun 10 2020 at 21:10)</a>:</h4>
<p>I don't think looking at this is that useful though</p>



<a name="200479895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200479895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200479895">(Jun 10 2020 at 21:33)</a>:</h4>
<p>heh ok</p>



<a name="200480332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200480332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200480332">(Jun 10 2020 at 21:37)</a>:</h4>
<p>so</p>



<a name="200480338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200480338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200480338">(Jun 10 2020 at 21:37)</a>:</h4>
<p>well maybe I'll take a look</p>



<a name="200480360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200480360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200480360">(Jun 10 2020 at 21:37)</a>:</h4>
<p>I was thinking that maybe I can try to do some of the changes, which might either convince me this is wrong-headed, or help in handling some of the thorny bits</p>



<a name="200562886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200562886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200562886">(Jun 11 2020 at 15:47)</a>:</h4>
<p>Will spend a few hours on this now</p>



<a name="200563010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200563010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200563010">(Jun 11 2020 at 15:48)</a>:</h4>
<p>I think my initial approach of starting by redefining <code>Predicate</code> is quite suboptimal, as I can't really test individual changes</p>



<a name="200563714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200563714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200563714">(Jun 11 2020 at 15:53)</a>:</h4>
<p>I am currently thinking about changing <code>Predicate</code> to contain a temporary field with the new <code>PredicateKind</code> definition and slowly change parts of the compiler to use this new field(e.g. by using a <code>fn kint</code> instead of <code>fn kind</code>). Then, once most uses of <code>kind</code> have been replaced we can remove the old enum and rename <code>kint</code> to <code>kind</code>.</p>



<a name="200573926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200573926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200573926">(Jun 11 2020 at 17:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Am I correct in the assumption that <code>ForAll(ForAll(inner))</code> makes no sense?</p>



<a name="200585795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200585795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200585795">(Jun 11 2020 at 18:25)</a>:</h4>
<p>define "make sense"</p>



<a name="200585800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200585800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200585800">(Jun 11 2020 at 18:25)</a>:</h4>
<p>I mean it has a well-defined meaning</p>



<a name="200585818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200585818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200585818">(Jun 11 2020 at 18:25)</a>:</h4>
<p>but it's not the most efficient construction I suppose</p>



<a name="200585955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200585955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200585955">(Jun 11 2020 at 18:27)</a>:</h4>
<p>Makes sense in the way that I can just panic if it comes up for now <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="200586183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200586183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200586183">(Jun 11 2020 at 18:28)</a>:</h4>
<p>heh, ok, I'm not sure why you would though :)</p>



<a name="200586194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200586194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200586194">(Jun 11 2020 at 18:28)</a>:</h4>
<p>sounds mildly suspicious</p>



<a name="200586223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200586223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200586223">(Jun 11 2020 at 18:28)</a>:</h4>
<p>but I don't think it would be easy to give rise to that situation right now</p>



<a name="200614172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200614172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200614172">(Jun 11 2020 at 22:15)</a>:</h4>
<p>From now on all the good stuff will probably happen on <a href="https://github.com/lcnr/rust/tree/forall-predicate-slow-heyho">https://github.com/lcnr/rust/tree/forall-predicate-slow-heyho</a> instead.</p>
<p>This should make it easier to make and review incremental changes. Will try to convert either elaborate or select this weekend.</p>



<a name="200761330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200761330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200761330">(Jun 13 2020 at 11:10)</a>:</h4>
<p>Getting the good error messages <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> </p>
<div class="codehilite"><pre><span></span><code>note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&amp;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;chalk_ir::Binders&lt;_&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
</code></pre></div>



<a name="200763231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200763231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200763231">(Jun 13 2020 at 12:07)</a>:</h4>
<p>Ok, can't spend more time on this today, tried to rework <code>process_obligation</code> to use <code>PredicateKint</code> which once again ended up infecting nearly every other part of the trait system. it might be better to add a bunch of <code>Binder::dummy</code> instead, wip commit is <a href="https://github.com/lcnr/rust/commit/4c95b9fdce0c9fb289efda5f5c8d983dc860488b">here</a></p>



<a name="200765603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200765603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200765603">(Jun 13 2020 at 13:07)</a>:</h4>
<p>nm, I did spend more time on this today. <span class="user-mention" data-user-id="116009">@nikomatsakis</span> I experimented a bit in <a href="https://github.com/rust-lang/rust/compare/master...lcnr:forall-predicate-what-and-why">https://github.com/rust-lang/rust/compare/master...lcnr:forall-predicate-what-and-why</a></p>



<a name="200765612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200765612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200765612">(Jun 13 2020 at 13:07)</a>:</h4>
<p>Most relevant is the last commit: <a href="https://github.com/rust-lang/rust/commit/578f95297cbce1885d07fa8824b33a68be828e88">https://github.com/rust-lang/rust/commit/578f95297cbce1885d07fa8824b33a68be828e88</a></p>



<a name="200765668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200765668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200765668">(Jun 13 2020 at 13:08)</a>:</h4>
<p>I try to convert to <code>PredicateKint</code> and correctly deal with <code>ForAll</code> in <code>process_obligations</code></p>



<a name="200765678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200765678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200765678">(Jun 13 2020 at 13:09)</a>:</h4>
<p>And then instantly rebind with <code>Binder::dummy</code> so I don't have to change all of the surrounding code</p>



<a name="200765744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200765744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200765744">(Jun 13 2020 at 13:10)</a>:</h4>
<p>This causes the following errors + ICE when compiling libcore</p>
<div class="codehilite"><pre><span></span><code>error[E0599]: no method named `count` found for struct `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u32&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;` in the current scope
    --&gt; src/libcore/num/bignum.rs:173:74
     |
100  | / macro_rules! define_bignum {
101  | |     ($name:ident: type=$ty:ty, n=$n:expr) =&gt; {
102  | |         /// Stack-allocated arbitrary-precision (up to certain limit) integer.
103  | |         ///
...    |
173  | |                 let zeros = digits.iter().rev().take_while(|&amp;&amp;x| x == 0).count();
     | |                                                            ------------  ^^^^^ method not found in `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u32&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;`
     | |                                                            |
     | |                                                            doesn&#39;t satisfy `&lt;_ as ops::function::FnOnce&lt;(&amp;&amp;u32,)&gt;&gt;::Output = bool`
     | |                                                            doesn&#39;t satisfy `_: ops::function::FnMut&lt;(&amp;&amp;u32,)&gt;`
...    |
477  | |     };
478  | | }
     | |_- in this expansion of `define_bignum!`
...
483  |   define_bignum!(Big32x40: type=Digit32, n=40);
     |   --------------------------------------------- in this macro invocation
     |
    ::: src/libcore/iter/adapters/mod.rs:1798:1
     |
1798 |   pub struct TakeWhile&lt;I, P&gt; {
     |   --------------------------
     |   |
     |   method `count` not found for this
     |   doesn&#39;t satisfy `_: iter::traits::iterator::Iterator`
     |
     = note: the method `count` exists but the following trait bounds were not satisfied:
             `&lt;[closure@src/libcore/num/bignum.rs:173:60: 173:72] as ops::function::FnOnce&lt;(&amp;&amp;u32,)&gt;&gt;::Output = bool`
             which is required by `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u32&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`
             `[closure@src/libcore/num/bignum.rs:173:60: 173:72]: ops::function::FnMut&lt;(&amp;&amp;u32,)&gt;`
             which is required by `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u32&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`
             `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u32&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`
             which is required by `&amp;mut iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u32&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`

error[E0599]: no method named `count` found for struct `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u8&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;` in the current scope
    --&gt; src/libcore/num/bignum.rs:173:74
     |
100  | / macro_rules! define_bignum {
101  | |     ($name:ident: type=$ty:ty, n=$n:expr) =&gt; {
102  | |         /// Stack-allocated arbitrary-precision (up to certain limit) integer.
103  | |         ///
...    |
173  | |                 let zeros = digits.iter().rev().take_while(|&amp;&amp;x| x == 0).count();
     | |                                                            ------------  ^^^^^ method not found in `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u8&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;`
     | |                                                            |
     | |                                                            doesn&#39;t satisfy `&lt;_ as ops::function::FnOnce&lt;(&amp;&amp;u8,)&gt;&gt;::Output = bool`
     | |                                                            doesn&#39;t satisfy `_: ops::function::FnMut&lt;(&amp;&amp;u8,)&gt;`
...    |
477  | |     };
478  | | }
     | |_- in this expansion of `define_bignum!`
...
488  |       define_bignum!(Big8x3: type=u8, n=3);
     |       ------------------------------------- in this macro invocation
     |
    ::: src/libcore/iter/adapters/mod.rs:1798:1
     |
1798 |   pub struct TakeWhile&lt;I, P&gt; {
     |   --------------------------
     |   |
     |   method `count` not found for this
     |   doesn&#39;t satisfy `_: iter::traits::iterator::Iterator`
     |
     = note: the method `count` exists but the following trait bounds were not satisfied:
             `&lt;[closure@src/libcore/num/bignum.rs:173:60: 173:72] as ops::function::FnOnce&lt;(&amp;&amp;u8,)&gt;&gt;::Output = bool`
             which is required by `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u8&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`
             `[closure@src/libcore/num/bignum.rs:173:60: 173:72]: ops::function::FnMut&lt;(&amp;&amp;u8,)&gt;`
             which is required by `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u8&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`
             `iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u8&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`
             which is required by `&amp;mut iter::adapters::TakeWhile&lt;iter::adapters::Rev&lt;slice::Iter&lt;&#39;_, u8&gt;&gt;, [closure@src/libcore/num/bignum.rs:173:60: 173:72]&gt;: iter::traits::iterator::Iterator`

error: internal compiler error: src/librustc_middle/ich/impls_ty.rs:94: StableHasher: unexpected region RePlaceholder(Placeholder { universe: U3, name: BrAnon(0) })
</code></pre></div>



<a name="200787528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200787528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200787528">(Jun 13 2020 at 21:58)</a>:</h4>
<p>OK, so I've investigated what's going on here.</p>



<a name="200787543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200787543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200787543">(Jun 13 2020 at 21:59)</a>:</h4>
<p>Minimised (no core) repro:</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(no_core, lang_items, optin_builtin_traits)]</span><span class="w"></span>
<span class="cp">#![feature(unboxed_closures)]</span><span class="w"></span>
<span class="cp">#![allow(unused)]</span><span class="w"></span>
<span class="cp">#![no_core]</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;sized&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="nb">Sized</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;copy&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="nb">Copy</span>: <span class="nb">Sized</span> <span class="p">{}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;freeze&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="n">auto</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Freeze</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;drop_in_place&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">drop_in_place</span><span class="o">&lt;</span><span class="n">T</span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="p">(</span><span class="n">t</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">T</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;dispatch_from_dyn&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">DispatchFromDyn</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// Empty.</span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;deref&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Deref</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Target</span>: <span class="o">?</span><span class="nb">Sized</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">deref</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">Self</span>::<span class="n">Target</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Deref</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">T</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">deref</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="o">*</span><span class="bp">self</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Deref</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">T</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">deref</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="o">*</span><span class="bp">self</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">P</span>: <span class="nc">Deref</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Deref</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Pin</span><span class="o">&lt;</span><span class="n">P</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">P</span>::<span class="n">Target</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">deref</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">P</span>::<span class="n">Target</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">loop</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;receiver&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Receiver</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// Empty.</span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Receiver</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="n">T</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Receiver</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">P</span>: <span class="nc">Receiver</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Receiver</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Pin</span><span class="o">&lt;</span><span class="n">P</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;fn_once&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">Args</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// The returned type after the call operator is used.</span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Output</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="sd">/// Performs the call operation.</span>
<span class="w">    </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;rust-call&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">call_once</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">args</span>: <span class="nc">Args</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;fn_mut&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="nb">FnMut</span><span class="o">&lt;</span><span class="n">Args</span><span class="o">&gt;</span>: <span class="nb">FnOnce</span><span class="o">&lt;</span><span class="n">Args</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// Performs the call operation.</span>
<span class="w">    </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;rust-call&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">call_mut</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">args</span>: <span class="nc">Args</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;fn&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="nb">Fn</span><span class="o">&lt;</span><span class="n">Args</span><span class="o">&gt;</span>: <span class="nb">FnMut</span><span class="o">&lt;</span><span class="n">Args</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// Performs the call operation.</span>
<span class="w">    </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;rust-call&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">call</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">args</span>: <span class="nc">Args</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;generator_state&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">enum</span> <span class="nc">GeneratorState</span><span class="o">&lt;</span><span class="n">Y</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Yielded</span><span class="p">(</span><span class="n">Y</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Complete</span><span class="p">(</span><span class="n">R</span><span class="p">),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;pin&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Pin</span><span class="o">&lt;</span><span class="n">P</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">pointer</span>: <span class="nc">P</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">&quot;generator&quot;</span><span class="cp">]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Generator</span><span class="o">&lt;</span><span class="n">R</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">()</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Yield</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Return</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">resume</span><span class="p">(</span><span class="bp">self</span>: <span class="nc">Pin</span><span class="o">&lt;&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">arg</span>: <span class="nc">R</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">GeneratorState</span><span class="o">&lt;</span><span class="bp">Self</span>::<span class="n">Yield</span><span class="p">,</span><span class="w"> </span><span class="bp">Self</span>::<span class="n">Return</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">f</span><span class="o">&lt;</span><span class="n">F</span>: <span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="kt">i32</span><span class="p">)</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">g</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">f</span><span class="p">(</span><span class="o">|</span><span class="n">x</span><span class="o">|</span><span class="w"> </span><span class="p">{});</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="200787567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200787567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200787567">(Jun 13 2020 at 22:00)</a>:</h4>
<p>The issue is that we deduce closure's signatures from the obligations on them.</p>



<a name="200787632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200787632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200787632">(Jun 13 2020 at 22:01)</a>:</h4>
<p>Currently we have <code>for&lt;'1&gt; [closure]: FnMut(&amp;'1 i32)</code>, but with your changes it's <code>[closure]: FnMut(&amp;'!1 i32)</code></p>



<a name="200787684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200787684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200787684">(Jun 13 2020 at 22:02)</a>:</h4>
<p>This causes us to deduce that the closure signature should be <code>fn(&amp;'? i32)</code> instead of <code>for&lt;'r&gt; fn('r i32)</code>, giving the error.</p>



<a name="200787694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200787694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200787694">(Jun 13 2020 at 22:02)</a>:</h4>
<p>/me thinks about how to fix this</p>



<a name="200789194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200789194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200789194">(Jun 13 2020 at 22:48)</a>:</h4>
<p>Beautiful:</p>
<div class="codehilite"><pre><span></span><code><span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">obligation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;*</span><span class="n">obligation</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">alt_obligation</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="k">loop</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">break</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">obligation</span><span class="p">.</span><span class="n">predicate</span><span class="p">.</span><span class="n">kint</span><span class="p">(</span><span class="n">infcx</span><span class="p">.</span><span class="n">tcx</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="n">ty</span>::<span class="n">PredicateKint</span>::<span class="n">ForAll</span><span class="p">(</span><span class="n">binder</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">pred</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">infcx</span><span class="p">.</span><span class="n">replace_bound_vars_with_placeholders</span><span class="p">(</span><span class="n">binder</span><span class="p">);</span><span class="w"></span>
<span class="w">                    </span><span class="n">alt_obligation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">obligation</span><span class="p">.</span><span class="n">with</span><span class="p">(</span><span class="n">pred</span><span class="p">.</span><span class="n">to_predicate</span><span class="p">(</span><span class="n">infcx</span><span class="p">.</span><span class="n">tcx</span><span class="p">));</span><span class="w"></span>
<span class="w">                    </span><span class="n">obligation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">alt_obligation</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="k">continue</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
<span class="w">         </span><span class="c1">// ...</span>
</code></pre></div>



<a name="200789396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200789396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200789396">(Jun 13 2020 at 22:55)</a>:</h4>
<p>And all the ui tests fail because this ends up being a partial impl of <a href="https://github.com/rust-lang/rust/issues/72493">#72493</a></p>



<a name="200804662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200804662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200804662">(Jun 14 2020 at 07:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116118">Matthew Jasper</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/200789194">said</a>:</p>
<blockquote>
<p>Beautiful:</p>
<div class="codehilite"><pre><span></span><code><span class="o">..</span><span class="p">.</span><span class="w"></span>
</code></pre></div>


</blockquote>
<p>Is this at the start of <code>process_obligation</code>?</p>



<a name="200809255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200809255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200809255">(Jun 14 2020 at 09:57)</a>:</h4>
<p>It's in the middle.</p>



<a name="200809259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200809259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200809259">(Jun 14 2020 at 09:57)</a>:</h4>
<p>where the match currently is</p>



<a name="200810819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200810819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200810819">(Jun 14 2020 at 10:42)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span> that's what I meant :) I don't quite get how this fixes it though. This seems to me like you mainly unwrap multiple <code>ForAll</code>s here</p>



<a name="200810822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200810822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200810822">(Jun 14 2020 at 10:42)</a>:</h4>
<p>Can you push your changes to github?</p>



<a name="200814355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200814355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200814355">(Jun 14 2020 at 12:23)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/compare/master...matthewjasper:forall-predicate-what-and-why-2?expand=1">https://github.com/rust-lang/rust/compare/master...matthewjasper:forall-predicate-what-and-why-2?expand=1</a> . It's rebased over  <a href="https://github.com/rust-lang/rust/issues/73180">#73180</a> .</p>



<a name="200814659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200814659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200814659">(Jun 14 2020 at 12:31)</a>:</h4>
<p>Thanks <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> Aaaah, you don't actually replace the bound vars when processing <code>ForAll(Trait | Projection)</code>.</p>



<a name="200814704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200814704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200814704">(Jun 14 2020 at 12:32)</a>:</h4>
<p>It's changed since I wrote that.</p>



<a name="200815062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200815062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200815062">(Jun 14 2020 at 12:43)</a>:</h4>
<p>I thought <a href="https://github.com/rust-lang/rust/compare/master...matthewjasper:forall-predicate-what-and-why-2?expand=1">https://github.com/rust-lang/rust/compare/master...matthewjasper:forall-predicate-what-and-why-2?expand=1</a> was the relevant branch <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="200815658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200815658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200815658">(Jun 14 2020 at 13:00)</a>:</h4>
<p>Sorry, since I meant wrote the comment yesterday</p>



<a name="200815887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200815887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200815887">(Jun 14 2020 at 13:07)</a>:</h4>
<p>wait,  "I wrote it" refers to the comment above, not the branch you sent me?</p>



<a name="200815893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200815893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200815893">(Jun 14 2020 at 13:07)</a>:</h4>
<p>So your solution has changed since the above comment, and the branch you sent me is up to date</p>



<a name="200815942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/200815942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#200815942">(Jun 14 2020 at 13:08)</a>:</h4>
<p>yes. I'm saying that the comment above showing the code is outdated. The branch is not.</p>



<a name="201080807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201080807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201080807">(Jun 16 2020 at 22:15)</a>:</h4>
<p>I am now using <a href="https://github.com/lcnr/rust/tree/forall-predicate-what-and-why-2">https://github.com/lcnr/rust/tree/forall-predicate-what-and-why-2</a> <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>
<p>Only implemented anonymize_predice today</p>



<a name="201195715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201195715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201195715">(Jun 17 2020 at 20:24)</a>:</h4>
<p>so the current wf code is somewhat unfortunate, as it is not made to deal with hrtb by simply skipping any potential wf obligations with escaping bound vars.</p>



<a name="201195814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201195814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201195814">(Jun 17 2020 at 20:25)</a>:</h4>
<p>afaict this is needed because <code>TypeWalker</code> simply skips the binder when walking <code>FnPtr</code> and <code>GeneratorWitness</code></p>



<a name="201195975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201195975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201195975">(Jun 17 2020 at 20:27)</a>:</h4>
<p>I think it's easiest to just do the same with <code>Predicate::ForAll</code>, even if it makes me somewhat unhappy</p>



<a name="201196019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201196019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201196019">(Jun 17 2020 at 20:27)</a>:</h4>
<p>I believe that the WF code</p>



<a name="201196032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201196032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201196032">(Jun 17 2020 at 20:27)</a>:</h4>
<p>basically skips obligations that involve bound regions</p>



<a name="201196047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201196047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201196047">(Jun 17 2020 at 20:28)</a>:</h4>
<p>so .. yeah .. skipping the binder is kind of right</p>



<a name="201196092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201196092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201196092">(Jun 17 2020 at 20:28)</a>:</h4>
<p>at least in so far as how that code is designed</p>



<a name="201208389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201208389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201208389">(Jun 17 2020 at 22:24)</a>:</h4>
<p>down to 373 mentions of <code>PredicateKind</code> <span aria-label="party ball" class="emoji emoji-1f38a" role="img" title="party ball">:party_ball:</span></p>



<a name="201287427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201287427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201287427">(Jun 18 2020 at 15:52)</a>:</h4>
<p>My last commit updates <code>elaborate</code>. I think this is kind of dangerous as we have to remember to rebind here.</p>
<p>Is there a better way to implement this? <a href="https://github.com/rust-lang/rust/commit/47f37ecff911c4a0931fd423a5389ecd39ddd1bc">https://github.com/rust-lang/rust/commit/47f37ecff911c4a0931fd423a5389ecd39ddd1bc</a></p>



<a name="201318036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201318036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201318036">(Jun 18 2020 at 19:55)</a>:</h4>
<p>it might be better to have <code>fn Predicate::kind</code> return <code>PredicateKind</code> instead of <code>Predicate</code> IMO</p>



<a name="201331068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201331068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201331068">(Jun 18 2020 at 22:03)</a>:</h4>
<p><code>PredicateKind</code> is dead, long live <code>PredicateKind</code>.</p>



<a name="201331204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201331204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201331204">(Jun 18 2020 at 22:04)</a>:</h4>
<p>So it now compiles after completely replacing <code>PredicateKind</code> with the new definition</p>



<a name="201331228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201331228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201331228">(Jun 18 2020 at 22:04)</a>:</h4>
<p>Still has 18 TODO's where the new impl is fairly dangerous/unclear</p>



<a name="201331271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201331271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201331271">(Jun 18 2020 at 22:05)</a>:</h4>
<p>and breaks while compiling libcore with</p>
<div class="codehilite"><pre><span></span><code>error[E0207]: the type parameter `B` is not constrained by the impl trait, self type, or predicates
    --&gt; src/libcore/iter/adapters/mod.rs:2379:6
     |
2379 | impl&lt;B, I, St, F&gt; Iterator for Scan&lt;I, St, F&gt;
     |      ^ unconstrained type parameter

error: aborting due to previous error
</code></pre></div>



<a name="201331429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201331429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201331429">(Jun 18 2020 at 22:07)</a>:</h4>
<p>Which is kind of surprising, I think I probablly missed a match on <code>kind</code> which only checks the variant and now doesn't work because its <code>ForAll(Pred)</code> instead of <code>Pred</code>.</p>



<a name="201331450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201331450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201331450">(Jun 18 2020 at 22:07)</a>:</h4>
<p>Will hopefully get to look further into it tomorrow</p>



<a name="201332001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201332001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201332001">(Jun 18 2020 at 22:13)</a>:</h4>
<p>I also would like some feedback on the remaining <code>TODO</code>s, these are mostly sections which are now fairly ugly/unsafe in how they are dealing with binders.</p>



<a name="201332145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201332145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201332145">(Jun 18 2020 at 22:15)</a>:</h4>
<p>Do we want force <code>PredicateKind::ForAll</code> to always bind something, that seems like it may improve some sections?</p>



<a name="201333382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201333382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201333382">(Jun 18 2020 at 22:29)</a>:</h4>
<p>Added some comments, and yes. Predicate should have a method that wraps itself in a for all only if it has escaping bound regions, possibly asserting that the result doesn't have escaping bound regions.</p>



<a name="201368270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201368270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201368270">(Jun 19 2020 at 09:21)</a>:</h4>
<p>Some <code>ForAll</code> end up with escaping bound regions:</p>
<div class="codehilite"><pre><span></span><code><span class="c1">// run-pass</span>
<span class="cp">#![allow(dead_code)]</span><span class="w"></span>
<span class="c1">// Issue #2263.</span>

<span class="c1">// Here, `f` is a function that takes a pointer `x` and a function</span>
<span class="c1">// `g`, where `g` requires its argument `y` to be in the same region</span>
<span class="c1">// that `x` is in.</span>
<span class="c1">// pretty-expanded FIXME #23616</span>

<span class="k">fn</span> <span class="nf">has_same_region</span><span class="p">(</span><span class="n">f</span>: <span class="nb">Box</span><span class="o">&lt;</span><span class="k">dyn</span><span class="w"> </span><span class="k">for</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">isize</span><span class="p">,</span><span class="w"> </span><span class="nb">Box</span><span class="o">&lt;</span><span class="k">dyn</span><span class="w"> </span><span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">isize</span><span class="p">)</span><span class="o">&gt;</span><span class="p">)</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// `f` should be the type that `wants_same_region` wants, but</span>
<span class="w">    </span><span class="c1">// right now the compiler complains that it isn&#39;t.</span>
<span class="w">    </span><span class="n">wants_same_region</span><span class="p">(</span><span class="n">f</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">wants_same_region</span><span class="p">(</span><span class="n">_f</span>: <span class="nb">Box</span><span class="o">&lt;</span><span class="k">dyn</span><span class="w"> </span><span class="k">for</span><span class="o">&lt;</span><span class="na">&#39;b</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="na">&#39;b</span><span class="w"> </span><span class="kt">isize</span><span class="p">,</span><span class="w"> </span><span class="nb">Box</span><span class="o">&lt;</span><span class="k">dyn</span><span class="w"> </span><span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="na">&#39;b</span><span class="w"> </span><span class="kt">isize</span><span class="p">)</span><span class="o">&gt;</span><span class="p">)</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>HAs the following predicate: <code>ForAll(Binder(TraitPredicate(&lt;FreshTy(0) as std::ops::FnOnce&lt;(&amp;'a isize,)&gt;&gt;)))</code></p>



<a name="201375096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201375096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201375096">(Jun 19 2020 at 10:50)</a>:</h4>
<p>Printing opaque types contains predicates with unbound regions <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="201379219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201379219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201379219">(Jun 19 2020 at 11:46)</a>:</h4>
<p>Hmm, all remaining tests fail in chalk</p>



<a name="201379363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201379363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201379363">(Jun 19 2020 at 11:48)</a>:</h4>
<p>One error is</p>
<div class="codehilite"><pre><span></span><code>thread &#39;rustc&#39; panicked at &#39;Skipped bound var index.&#39;, src/librustc_traits/chalk/lowering.rs:520:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic
</code></pre></div>



<a name="201380903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201380903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201380903">(Jun 19 2020 at 12:07)</a>:</h4>
<p>Opened <a href="https://github.com/rust-lang/rust/pull/73503">https://github.com/rust-lang/rust/pull/73503</a> for now, still have to fix chalk though</p>



<a name="201382187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201382187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201382187">(Jun 19 2020 at 12:24)</a>:</h4>
<p>More detailed: <code>error: internal compiler error: src/librustc_traits/chalk/lowering.rs:520: Skipped bound var index: ty=Binder(TraitPredicate(&lt;U as std::marker::Sized&gt;)), parameters={1: Ty(())}</code></p>



<a name="201382686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201382686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201382686">(Jun 19 2020 at 12:31)</a>:</h4>
<p>Is <code>U</code> a bound var? What does using <code>-Zverbose</code> show?</p>



<a name="201382826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201382826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201382826">(Jun 19 2020 at 12:32)</a>:</h4>
<p>exactly the same <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="201382988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201382988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201382988">(Jun 19 2020 at 12:34)</a>:</h4>
<p>Ugh, -Zverbose doesn't affect bound types. <span aria-label="sad" class="emoji emoji-2639" role="img" title="sad">:sad:</span></p>



<a name="201387842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201387842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201387842">(Jun 19 2020 at 13:16)</a>:</h4>
<p>Updating the chalk lowering there <em>should</em> be fairly straightforward</p>



<a name="201387964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201387964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201387964">(Jun 19 2020 at 13:17)</a>:</h4>
<p>I thought so too <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="201388056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201388056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201388056">(Jun 19 2020 at 13:18)</a>:</h4>
<p>These should be the only relevant changes <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> <a href="https://github.com/rust-lang/rust/pull/73503/files#diff-c04a0fadb0b4314f668eb30e70a2f659">https://github.com/rust-lang/rust/pull/73503/files#diff-c04a0fadb0b4314f668eb30e70a2f659</a></p>



<a name="201388258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201388258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201388258">(Jun 19 2020 at 13:20)</a>:</h4>
<p>It may also be that something else is still wrong which isn't checked elsewhere</p>



<a name="201388555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201388555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201388555">(Jun 19 2020 at 13:22)</a>:</h4>
<p>I've commented with what I think the issue is</p>



<a name="201390773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201390773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201390773">(Jun 19 2020 at 13:39)</a>:</h4>
<p>will try</p>



<a name="201399701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201399701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201399701">(Jun 19 2020 at 14:47)</a>:</h4>
<p>hm, we have still 8 failing chalk tests :/</p>



<a name="201404592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201404592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201404592">(Jun 19 2020 at 15:22)</a>:</h4>
<p>yeah, elaboration is ungreat in general</p>



<a name="201404608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201404608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201404608">(Jun 19 2020 at 15:22)</a>:</h4>
<p>it's sort of a violation of the approach I think we should be taking</p>



<a name="201404616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201404616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201404616">(Jun 19 2020 at 15:23)</a>:</h4>
<p>(but I think it can be handled)</p>



<a name="201404624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201404624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201404624">(Jun 19 2020 at 15:23)</a>:</h4>
<p>it's not how chalk handles things though</p>



<a name="201404668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201404668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201404668">(Jun 19 2020 at 15:23)</a>:</h4>
<p>The backtraceseems to be kind of broken:</p>
<div class="codehilite"><pre><span></span><code>thread &#39;rustc&#39; panicked at &#39;assertion failed: `(left == right)`
  left: `^1`,
 right: `^0`&#39;, /home/programming/rust3/src/libstd/macros.rs:16:9
stack backtrace:
   0: &lt;std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display&gt;::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::sys_common::backtrace::print
   4: std::panicking::default_hook::{{closure}}
   5: std::panicking::default_hook
   6: &lt;alloc::boxed::Box&lt;F&gt; as core::ops::function::Fn&lt;A&gt;&gt;::call
             at ./src/liballoc/boxed.rs:1090
   7: rustc_driver::report_ice
             at src/librustc_driver/lib.rs:1159
   8: std::panicking::rust_panic_with_hook
   9: rust_begin_unwind
  10: std::panicking::begin_panic_fmt
  11: &lt;&amp;chalk_ir::SubstFolder&lt;I&gt; as chalk_ir::fold::Folder&lt;I&gt;&gt;::fold_free_var_ty
             at ./src/libstd/macros.rs:16
  12: &lt;chalk_ir::Ty&lt;I&gt; as chalk_ir::fold::SuperFold&lt;I,TI&gt;&gt;::super_fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/fold.rs:342
  13: &lt;chalk_ir::Ty&lt;I&gt; as chalk_ir::fold::Fold&lt;I,TI&gt;&gt;::fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/fold.rs:315
  14: chalk_ir::_DERIVE_chalk_ir_fold_Fold_I_TI_FOR_WellFormed::&lt;impl chalk_ir::fold::Fold&lt;I,_TI&gt; for chalk_ir::WellFormed&lt;I&gt;&gt;::fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/lib.rs:957
  15: chalk_ir::_DERIVE_chalk_ir_fold_Fold_I_TI_FOR_DomainGoal::&lt;impl chalk_ir::fold::Fold&lt;I,_TI&gt; for chalk_ir::DomainGoal&lt;I&gt;&gt;::fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/lib.rs:1019
  16: chalk_ir::_DERIVE_chalk_ir_fold_Fold_I_TI_FOR_GoalData::&lt;impl chalk_ir::fold::Fold&lt;I,_TI&gt; for chalk_ir::GoalData&lt;I&gt;&gt;::fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/lib.rs:1863
  17: &lt;chalk_ir::Goal&lt;I&gt; as chalk_ir::fold::SuperFold&lt;I,TI&gt;&gt;::super_fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/fold.rs:455
  18: &lt;chalk_ir::Goal&lt;I&gt; as chalk_ir::fold::Fold&lt;I,TI&gt;&gt;::fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/fold.rs:436
  19: chalk_ir::_DERIVE_chalk_ir_fold_Fold_I_TI_FOR_InEnvironment::&lt;impl chalk_ir::fold::Fold&lt;_I,_TI&gt; for chalk_ir::InEnvironment&lt;G&gt;&gt;::fold_with
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/lib.rs:79
  20: chalk_ir::Substitution&lt;I&gt;::apply
             at /home/programming/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.10.0/src/lib.rs:2013
  21: chalk_solve::infer::InferenceTable&lt;I&gt;::from_canonical
</code></pre></div>



<a name="201404815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201404815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201404815">(Jun 19 2020 at 15:24)</a>:</h4>
<p>It seems like rustc itself doesn't really care about bound vars, as both the previous approach and the suggestion by <span class="user-mention silent" data-user-id="116118">Matthew Jasper</span> seem to work</p>



<a name="201407274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201407274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201407274">(Jun 19 2020 at 15:45)</a>:</h4>
<p>Ok, so the panic location is</p>
<div class="codehilite"><pre><span></span><code><span class="w"> </span><span class="k">fn</span> <span class="nf">fold_free_var_ty</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bound_var</span>: <span class="nc">BoundVar</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">outer_binder</span>: <span class="nc">DebruijnIndex</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Fallible</span><span class="o">&lt;</span><span class="n">Ty</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">bound_var</span><span class="p">.</span><span class="n">debruijn</span><span class="p">,</span><span class="w"> </span><span class="n">DebruijnIndex</span>::<span class="n">INNERMOST</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">bound_var</span><span class="p">.</span><span class="n">index</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ty</span><span class="p">.</span><span class="n">assert_ty_ref</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">interner</span><span class="p">());</span><span class="w"></span>
<span class="w">        </span><span class="nb">Ok</span><span class="p">(</span><span class="n">ty</span><span class="p">.</span><span class="n">shifted_in_from</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">interner</span><span class="p">(),</span><span class="w"> </span><span class="n">outer_binder</span><span class="p">))</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="201407435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201407435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201407435">(Jun 19 2020 at 15:46)</a>:</h4>
<p>in chalk itself, so afaict chalk expects <code>Predicate</code>s to not have unbound variables</p>



<a name="201407494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201407494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201407494">(Jun 19 2020 at 15:46)</a>:</h4>
<p>And I missed a binder somewhere</p>



<a name="201409183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201409183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201409183">(Jun 19 2020 at 15:59)</a>:</h4>
<p>Well, probably. I'll try to go through the PR soon.</p>



<a name="201410393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201410393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201410393">(Jun 19 2020 at 16:08)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> oh interesting</p>



<a name="201410409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201410409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201410409">(Jun 19 2020 at 16:08)</a>:</h4>
<p>I'm having that problem locally</p>



<a name="201410478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201410478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201410478">(Jun 19 2020 at 16:08)</a>:</h4>
<p>(When I updated with the <code>ProgramClauseData</code> update)</p>



<a name="201410527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201410527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201410527">(Jun 19 2020 at 16:09)</a>:</h4>
<p>I feel like I probably missing something somewhere</p>



<a name="201411152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201411152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201411152">(Jun 19 2020 at 16:14)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> the strange backtraces or the ICE?</p>



<a name="201412630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201412630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201412630">(Jun 19 2020 at 16:27)</a>:</h4>
<p>The assertion panic</p>



<a name="201412873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201412873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201412873">(Jun 19 2020 at 16:29)</a>:</h4>
<p>Actually, I might have fixed it. Let me check</p>



<a name="201413608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201413608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201413608">(Jun 19 2020 at 16:36)</a>:</h4>
<p>yeah nevermind, I did fix it</p>



<a name="201413913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201413913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201413913">(Jun 19 2020 at 16:39)</a>:</h4>
<p>can you push your changes to the chalk lowering? I'll take a look</p>



<a name="201414165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414165">(Jun 19 2020 at 16:42)</a>:</h4>
<p>Actually, I found something suspect</p>



<a name="201414167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414167">(Jun 19 2020 at 16:42)</a>:</h4>
<p>These are the changes to lowering, which should not actually change anything for chalk <a href="https://github.com/rust-lang/rust/pull/73503/files#diff-c04a0fadb0b4314f668eb30e70a2f659">https://github.com/rust-lang/rust/pull/73503/files#diff-c04a0fadb0b4314f668eb30e70a2f659</a></p>
<p>obv not how <code>ForAll</code> should actually be handled</p>



<a name="201414371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414371">(Jun 19 2020 at 16:44)</a>:</h4>
<p>made some comments</p>



<a name="201414463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414463">(Jun 19 2020 at 16:45)</a>:</h4>
<p>basically, you're wrapping the predicates in a <code>bind</code>, but don't shift the vars. Then the code below wraps them in a <code>ForAll</code>, so the bound vars are wrong</p>



<a name="201414600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414600">(Jun 19 2020 at 16:46)</a>:</h4>
<p>I don't think that's the problem, as I only rebind the binders skipped at the beginning of the match</p>



<a name="201414624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414624">(Jun 19 2020 at 16:47)</a>:</h4>
<p>I match on <code>pred.ignore_qualifiers(tcx).skip_binder().kind()</code></p>



<a name="201414646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414646">(Jun 19 2020 at 16:47)</a>:</h4>
<p>And <code>ignore_qualifiers</code> should correctly shift the bound vars</p>



<a name="201414740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414740">(Jun 19 2020 at 16:48)</a>:</h4>
<p>So this should be equal to <code>Binder::bind(value.skip_binder())</code> which should just be <code>identity</code></p>



<a name="201414801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414801">(Jun 19 2020 at 16:48)</a>:</h4>
<p>ah, hmm</p>



<a name="201414839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414839">(Jun 19 2020 at 16:49)</a>:</h4>
<p>But I realized I am doing the same thing somewhere else where it shouldn't be correct</p>



<a name="201414853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414853">(Jun 19 2020 at 16:49)</a>:</h4>
<p>thanks <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="201414934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414934">(Jun 19 2020 at 16:50)</a>:</h4>
<p>Why not just call <code>collect_bound_vars</code> at the top of the function? Rather than <code>skip_binders</code>?</p>



<a name="201414936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201414936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201414936">(Jun 19 2020 at 16:50)</a>:</h4>
<p>or I think I do...</p>



<a name="201415176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201415176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201415176">(Jun 19 2020 at 16:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/201414934">said</a>:</p>
<blockquote>
<p>Why not just call <code>collect_bound_vars</code> at the top of the function? Rather than <code>skip_binders</code>?</p>
</blockquote>
<p>Yeah, that's honestly the easier/cleaner/correct way</p>



<a name="201415250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201415250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201415250">(Jun 19 2020 at 16:52)</a>:</h4>
<p>and more or less how I <em>expected</em> this code to be written</p>



<a name="201415284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201415284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201415284">(Jun 19 2020 at 16:52)</a>:</h4>
<p>(I'm not saying it <em>is</em> the problem)</p>



<a name="201415487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201415487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201415487">(Jun 19 2020 at 16:54)</a>:</h4>
<p>Oh, I guess you use that pattern everywhere</p>



<a name="201415877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201415877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201415877">(Jun 19 2020 at 16:58)</a>:</h4>
<p>I had about 300 errors to comb through, so I did a lot of semi automatic binder movement <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> <br>
I think that pattern is absolutely horrible, as we are forced to manually rebind the given variant.</p>



<a name="201415965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201415965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201415965">(Jun 19 2020 at 16:59)</a>:</h4>
<p>I don't really know how to fix this, except by adding a <code>PolyPredicateKind</code> enum which is similar to the old one and building it on the fly when calling <code>ignore_qualifiers</code> <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="201416912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201416912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201416912">(Jun 19 2020 at 17:07)</a>:</h4>
<p>found another potentially suspect place</p>



<a name="201416926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201416926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201416926">(Jun 19 2020 at 17:07)</a>:</h4>
<p>though it's not in chalk lowering</p>



<a name="201416953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201416953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201416953">(Jun 19 2020 at 17:07)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/73503/files#diff-be27d6a6af7ff4ca2d8882a7d8d44d21R152">https://github.com/rust-lang/rust/pull/73503/files#diff-be27d6a6af7ff4ca2d8882a7d8d44d21R152</a></p>



<a name="201417035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417035">(Jun 19 2020 at 17:08)</a>:</h4>
<p>For predicate, you <code>skip_binder</code> in one case (<code>ForAll</code>), but not in the other</p>



<a name="201417044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417044">(Jun 19 2020 at 17:08)</a>:</h4>
<p>jup</p>



<a name="201417054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417054">(Jun 19 2020 at 17:08)</a>:</h4>
<p>but below you unconditionally bind</p>



<a name="201417274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417274">(Jun 19 2020 at 17:10)</a>:</h4>
<p>thanks <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> let's see if this fixes it</p>



<a name="201417448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417448">(Jun 19 2020 at 17:12)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/73503/files#diff-d50f263d8091a7b5a01fb336a499c4b9R1071">https://github.com/rust-lang/rust/pull/73503/files#diff-d50f263d8091a7b5a01fb336a499c4b9R1071</a> <code>cond</code> is missing a <code>bind</code>?</p>



<a name="201417505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417505">(Jun 19 2020 at 17:12)</a>:</h4>
<p>oh you rebind below</p>



<a name="201417711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417711">(Jun 19 2020 at 17:15)</a>:</h4>
<p>(not a problem but <a href="https://github.com/rust-lang/rust/pull/73503/files#diff-d50f263d8091a7b5a01fb336a499c4b9R1459">https://github.com/rust-lang/rust/pull/73503/files#diff-d50f263d8091a7b5a01fb336a499c4b9R1459</a> doesn't actually need a bind I don't think)</p>



<a name="201417867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417867">(Jun 19 2020 at 17:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/201416953">said</a>:</p>
<blockquote>
<p><a href="https://github.com/rust-lang/rust/pull/73503/files#diff-be27d6a6af7ff4ca2d8882a7d8d44d21R152">https://github.com/rust-lang/rust/pull/73503/files#diff-be27d6a6af7ff4ca2d8882a7d8d44d21R152</a></p>
</blockquote>
<p>sadly not enough, I still have 7 failing tests</p>



<a name="201417926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417926">(Jun 19 2020 at 17:17)</a>:</h4>
<p>that's one fewer right?</p>



<a name="201417966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417966">(Jun 19 2020 at 17:17)</a>:</h4>
<p>I think <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="201417980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417980">(Jun 19 2020 at 17:17)</a>:</h4>
<p><span aria-label="rolling eyes" class="emoji emoji-1f644" role="img" title="rolling eyes">:rolling_eyes:</span></p>



<a name="201417994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201417994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201417994">(Jun 19 2020 at 17:17)</a>:</h4>
<p>it is</p>



<a name="201418013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201418013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201418013">(Jun 19 2020 at 17:17)</a>:</h4>
<p>at least if I didn't fat finger before</p>



<a name="201418309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201418309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201418309">(Jun 19 2020 at 17:20)</a>:</h4>
<p>so much diff to go through</p>



<a name="201418998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201418998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201418998">(Jun 19 2020 at 17:25)</a>:</h4>
<blockquote>
<p>let proj = proj;</p>
</blockquote>
<p>The good code</p>



<a name="201419577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201419577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201419577">(Jun 19 2020 at 17:31)</a>:</h4>
<p>Okay, I didn't see anything else :(</p>



<a name="201434435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201434435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201434435">(Jun 19 2020 at 20:03)</a>:</h4>
<p>I think I know what the problem is... <code>Binder::wrap_nonbinding</code> currently also shifts already bound vars if I am not mistaken</p>



<a name="201434778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201434778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201434778">(Jun 19 2020 at 20:07)</a>:</h4>
<p>so if we have <code>Trait(for&lt;'a&gt; fn(&amp;'a (), &amp;'b ()): Clone)</code> where <code>'b</code> is unbound, <code>Binder::wrap_nonbinding</code> currently also shifts <code>'a</code> outwards,<br>
meaning that this is changed to <code>Forall(for&lt;'a&gt;: Trait(fn(&amp;'a (), &amp;'b ()): Clone)</code>, which is incorrect</p>



<a name="201434848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201434848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201434848">(Jun 19 2020 at 20:08)</a>:</h4>
<p>or did I miss something?</p>



<a name="201434867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201434867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201434867">(Jun 19 2020 at 20:08)</a>:</h4>
<p>It shouldn't. shift_in should handle that.</p>



<a name="201434953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201434953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201434953">(Jun 19 2020 at 20:09)</a>:</h4>
<p>/me wishes that there were unit tests for this sort of thing.</p>



<a name="201435169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201435169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201435169">(Jun 19 2020 at 20:11)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">if</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">amount</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">debruijn</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">current_index</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">r</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="201435180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201435180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201435180">(Jun 19 2020 at 20:11)</a>:</h4>
<p>we start with index 0</p>



<a name="201435257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201435257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201435257">(Jun 19 2020 at 20:12)</a>:</h4>
<p>nm, that seems correct</p>



<a name="201435274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201435274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201435274">(Jun 19 2020 at 20:12)</a>:</h4>
<p>was confused for a second</p>



<a name="201470705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201470705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201470705">(Jun 20 2020 at 09:50)</a>:</h4>
<p>I really don't know what is going wrong here :/ I think all remaining failures are in</p>
<div class="codehilite"><pre><span></span><code><span class="w"> </span><span class="k">fn</span> <span class="nf">fold_free_var_ty</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bound_var</span>: <span class="nc">BoundVar</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">outer_binder</span>: <span class="nc">DebruijnIndex</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Fallible</span><span class="o">&lt;</span><span class="n">Ty</span><span class="o">&lt;</span><span class="n">I</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">bound_var</span><span class="p">.</span><span class="n">debruijn</span><span class="p">,</span><span class="w"> </span><span class="n">DebruijnIndex</span>::<span class="n">INNERMOST</span><span class="p">);</span><span class="w"> </span><span class="c1">// here</span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">bound_var</span><span class="p">.</span><span class="n">index</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ty</span><span class="p">.</span><span class="n">assert_ty_ref</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">interner</span><span class="p">());</span><span class="w"></span>
<span class="w">        </span><span class="nb">Ok</span><span class="p">(</span><span class="n">ty</span><span class="p">.</span><span class="n">shifted_in_from</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">interner</span><span class="p">(),</span><span class="w"> </span><span class="n">outer_binder</span><span class="p">))</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="201487244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201487244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201487244">(Jun 20 2020 at 17:11)</a>:</h4>
<p>I don't <em>think</em> it's a Chalk problem</p>



<a name="201487270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201487270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201487270">(Jun 20 2020 at 17:11)</a>:</h4>
<p>But it is a little interesting you're only getting errors in Chalk tests</p>



<a name="201487338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201487338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201487338">(Jun 20 2020 at 17:12)</a>:</h4>
<p>Though Chalk is probably a bit more sensitive to debruijn indices than rustc</p>



<a name="201487357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201487357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201487357">(Jun 20 2020 at 17:13)</a>:</h4>
<p>Or maybe there's a code path that the Chalk integration is hitting that the rest of rustc isn't</p>



<a name="201489599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201489599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201489599">(Jun 20 2020 at 18:06)</a>:</h4>
<p>Also, <span class="user-mention" data-user-id="216206">@lcnr</span> I pulled your changes, not all of them fail there. <code>builtin-copy-clone</code> fails in <code>fold_free_var_lifetime</code></p>



<a name="201489651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201489651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201489651">(Jun 20 2020 at 18:07)</a>:</h4>
<p>If it helps, this is an example of one of the goals that is failing:</p>
<div class="codehilite"><pre><span></span><code>: :     canonical: Canonical {
: :         value: InEnvironment {
: :             environment: Env([for[] FromEnv(Ty(!0_0): TraitId(Trait(DefId(2:1910 ~ core[13dc]::marker[0]::Sized[0])))), for[] FromEnv(Ty(!0_0): TraitId(Trait(DefId(2:1604 ~ core[13dc]::clone[0]::Clone[0])))), FromEnv(!0_0)]),
: :             goal: WellFormed(for&lt;0&gt; [Ty(StructId(Ref(Not))&lt;Lifetime(&#39;^2.0), Ty(!0_0)&gt;), Ty(!0_0)]),
: :         },
: :         binders: [Lifetime(U0)],
: :     },
: :     universes: 1,
</code></pre></div>



<a name="201489699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201489699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201489699">(Jun 20 2020 at 18:08)</a>:</h4>
<p>Pretty sure it's that <code>'^2.0</code> there</p>



<a name="201490000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201490000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201490000">(Jun 20 2020 at 18:15)</a>:</h4>
<p>Which comes from this <code>ChalkEnvironmentAndGoal</code>:</p>
<div class="codehilite"><pre><span></span><code>ChalkEnvironmentAndGoal {
        environment: [
            Predicate(
                TraitPredicate(&lt;T as std::marker::Sized&gt;),
            ),
            Predicate(
                TraitPredicate(&lt;T as std::clone::Clone&gt;),
            ),
            TypeFromEnv(
                T,
            ),
        ],
        goal: WellFormed(fn(&amp;T) -&gt; T),
    }
</code></pre></div>



<a name="201490173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201490173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201490173">(Jun 20 2020 at 18:18)</a>:</h4>
<p>It's probably this line: <a href="https://github.com/rust-lang/rust/pull/73503/files#diff-c04a0fadb0b4314f668eb30e70a2f659L185">https://github.com/rust-lang/rust/pull/73503/files#diff-c04a0fadb0b4314f668eb30e70a2f659L185</a></p>



<a name="201490720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201490720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201490720">(Jun 20 2020 at 18:31)</a>:</h4>
<p>yep that's the problem</p>



<a name="201490786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201490786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201490786">(Jun 20 2020 at 18:33)</a>:</h4>
<p>Changing that to <code>WellFormed</code> goal to </p>
<div class="codehilite"><pre><span></span><code>                    _ =&gt; {
                        let (ty, binders, _named_regions) = collect_bound_vars(interner, interner.tcx, &amp;ty::Binder::bind(ty));

                        chalk_ir::GoalData::Quantified(
                            chalk_ir::QuantifierKind::ForAll,
                            chalk_ir::Binders::new(
                                binders,
                                chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed(
                                    chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
                                ))
                                .intern(interner),
                            ),
                        )
                    }
</code></pre></div>


<p>fixes it</p>



<a name="201496727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201496727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201496727">(Jun 20 2020 at 20:47)</a>:</h4>
<p>ahhhhh, so well formed can now be bound <span aria-label="sweat" class="emoji emoji-1f613" role="img" title="sweat">:sweat:</span></p>



<a name="201496789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201496789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201496789">(Jun 20 2020 at 20:48)</a>:</h4>
<p>thank you for taking your time and looking into this <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> I really appreciate this</p>



<a name="201497009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201497009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201497009">(Jun 20 2020 at 20:53)</a>:</h4>
<p>Well, no, the issue is that <code>ignore_qualifiers</code> adjusts the indices as if it were.</p>



<a name="201498008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498008">(Jun 20 2020 at 21:14)</a>:</h4>
<p>ok, let's see if I got the correct now <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="201498016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498016">(Jun 20 2020 at 21:14)</a>:</h4>
<p>so we can have unbound variables in predicates</p>



<a name="201498039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498039">(Jun 20 2020 at 21:15)</a>:</h4>
<p>Yes, it's not common, but it can happen.</p>



<a name="201498042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498042">(Jun 20 2020 at 21:15)</a>:</h4>
<p><code>ignore_qualifiers</code> binds the predicate and moves unbound variables one level outwards, so they remain unbound</p>



<a name="201498070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498070">(Jun 20 2020 at 21:15)</a>:</h4>
<p>Well, it's common when we canonicalize, since that replaces inference variables with bound vars.</p>



<a name="201498073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498073">(Jun 20 2020 at 21:16)</a>:</h4>
<p>as we don't use this newly introduced binder for <code>WellFormed</code> predicates, the original unbound variables are now on the wrong level</p>



<a name="201498129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498129">(Jun 20 2020 at 21:16)</a>:</h4>
<p>yes</p>



<a name="201498238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498238">(Jun 20 2020 at 21:18)</a>:</h4>
<p>ok, that makes sense to me <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> This seems kind of dangerous as we don't use the binder in other situations too which only works right now because these locations don't have to deal with unbound variables</p>



<a name="201498254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498254">(Jun 20 2020 at 21:19)</a>:</h4>
<p>I think I should probably split <code>ignore_qualifiers</code> into two versions where the recommended one panics on unbound variables</p>



<a name="201498333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201498333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201498333">(Jun 20 2020 at 21:20)</a>:</h4>
<p>Makes sense.</p>



<a name="201507307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201507307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201507307">(Jun 21 2020 at 00:36)</a>:</h4>
<p>In this case, the bound var (lifetime) comes from the binders in canonicalization</p>



<a name="201507385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201507385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201507385">(Jun 21 2020 at 00:38)</a>:</h4>
<p>it's also worth nothing that the chalk lowering is especially sensitive to bound vars (and shifting since we replace some things with them eagerly</p>



<a name="201507486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201507486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201507486">(Jun 21 2020 at 00:41)</a>:</h4>
<p>In <em>this</em> particular case, we <em>might</em> just be able to use <code>VariableKinds::empty()</code> for the binders, but I'm not sure</p>



<a name="201531761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201531761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201531761">(Jun 21 2020 at 12:11)</a>:</h4>
<p>might be ready for review now, tests are now all passing</p>



<a name="201531998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201531998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201531998">(Jun 21 2020 at 12:19)</a>:</h4>
<p>rustdoc still fails some tests, will look into them later :/</p>



<a name="201664525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201664525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201664525">(Jun 22 2020 at 21:40)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> so I've not read the ~100 unread comments I had in this topic but should I review the PR now?</p>



<a name="201664534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201664534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201664534">(Jun 22 2020 at 21:40)</a>:</h4>
<p>seems like yes</p>



<a name="201691971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201691971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201691971">(Jun 23 2020 at 06:42)</a>:</h4>
<p>I think so <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="201695202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201695202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201695202">(Jun 23 2020 at 07:32)</a>:</h4>
<p>There is still the fairly general problem of using <code>predicate.ignore_qualifiers().skip_binder().kind()</code> in a lot of places,<br>
but I am not sure what's the best solution here</p>



<a name="201793301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793301">(Jun 23 2020 at 22:40)</a>:</h4>
<p>Yeah, I'm reading it through and making some notes</p>



<a name="201793322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793322">(Jun 23 2020 at 22:41)</a>:</h4>
<p>I am reminded of some things I did in the past, e.g., splitting out <code>Predicate</code> into <code>PredicateAtom</code> (no binders) and <code>Predicate</code></p>



<a name="201793332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793332">(Jun 23 2020 at 22:41)</a>:</h4>
<p>though I can't remember if that was a change I wound up abandoning in the end</p>



<a name="201793340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793340">(Jun 23 2020 at 22:41)</a>:</h4>
<p>in any case I feel like we can do this cleaner</p>



<a name="201793365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793365">(Jun 23 2020 at 22:41)</a>:</h4>
<p>though I admit it's not totally obvious how ;)</p>



<a name="201793436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793436">(Jun 23 2020 at 22:42)</a>:</h4>
<p>one question to consider is how much to iterate "in branch" versus iterating 'in tree' -- i.e., should we land even if we plan to iterate</p>



<a name="201793448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793448">(Jun 23 2020 at 22:42)</a>:</h4>
<p>we should proabbly do a perf run too</p>



<a name="201793505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793505">(Jun 23 2020 at 22:43)</a>:</h4>
<p>I'm pushing to nikomatsakis/forall-predicate-what-and-why-2 in any case</p>



<a name="201793515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793515">(Jun 23 2020 at 22:43)</a>:</h4>
<p>going to have to stop soon but I will resume</p>



<a name="201793533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201793533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201793533">(Jun 23 2020 at 22:43)</a>:</h4>
<p>(I'm just editing comments into the source for now, since a change of this size is easier to review "in tree" than via github)</p>



<a name="201818476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201818476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201818476">(Jun 24 2020 at 07:31)</a>:</h4>
<p>looking at your branch, what's the best way to interact here? Should I open comments on your commit?</p>



<a name="201818483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201818483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201818483">(Jun 24 2020 at 07:31)</a>:</h4>
<p>also what does ndm mean?</p>



<a name="201857708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201857708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201857708">(Jun 24 2020 at 14:52)</a>:</h4>
<p>those are my initials for easy grepping :)</p>



<a name="201857749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201857749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201857749">(Jun 24 2020 at 14:53)</a>:</h4>
<p>as for interaction, idk, you can just ping me here I guess, I'll convert them to comments on the PR, or I could push the commits to your branch...</p>



<a name="201861798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201861798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201861798">(Jun 24 2020 at 15:21)</a>:</h4>
<blockquote>
<p>Is there a good reason NOT to always create the <code>ForAll</code> here? Perhaps we want a helper that, given a <code>Binder&lt;Predicate&gt;</code> checks for escaping variables in the predicate and either constructs a for-all or discards the binder?</p>
</blockquote>
<p><span class="user-mention silent" data-user-id="116118">Matthew Jasper</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/201333382">said</a>:</p>
<blockquote>
<p>Added some comments, and yes. Predicate should have a method that wraps itself in a for all only if it has escaping bound regions, possibly asserting that the result doesn't have escaping bound regions.</p>
</blockquote>
<p>Was the reason for this design, I have since added <code>fn potentially_qualified</code> which does exactly that (and has to be renamed to <code>potentially_quantified</code> <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span>)</p>



<a name="201861835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201861835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201861835">(Jun 24 2020 at 15:21)</a>:</h4>
<blockquote>
<p>ndm let's add <code>to_predicate_or_return</code> or something?</p>
</blockquote>
<p>yes</p>



<a name="201862484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201862484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201862484">(Jun 24 2020 at 15:26)</a>:</h4>
<p>about <code>ignore_quantifiers</code></p>
<blockquote>
<p>this doesn't quite work like I expect. I expected it to return <code>Option&lt;Predicate&lt;'tcx&gt;&gt;</code> probably, just "skipping" the binders basically. Interesting.</p>
</blockquote>
<p>I wanted to make skipping binders explicit, as it can lead to problems if not handled correctly and think that simply <code>ignore_quantifiers</code> is "too easy to use".</p>



<a name="201868106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201868106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201868106">(Jun 24 2020 at 16:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/201861835">said</a>:</p>
<blockquote>
<blockquote>
<p>ndm let's add <code>to_predicate_or_return</code> or something?</p>
</blockquote>
<p>yes</p>
</blockquote>
<p>Added <code>tcx.reuse_or_mk_predicate</code>, copying the signature of <code>reuse_or_mk_region</code></p>



<a name="201869041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869041">(Jun 24 2020 at 16:13)</a>:</h4>
<blockquote>
<div class="codehilite"><pre><span></span><code>    // XXX ndm it feels like we can get cleaner here, can&#39;t we?
    // XXX certainly the *straightforward* thing would be to have
    // XXX nested foralls. I.e., if we have `forall&lt;...&gt; X`, then
    // XXX we can elaborate XXX `X` in a straightforward way, but
    // XXX we&#39;ll get `forall&lt;...&gt; forall&lt;..&gt; X`. How much of a problem is that?
    // XXX
    // XXX we could certainly &quot;flatten&quot; predicates too.
    // XXX
    // XXX I&#39;m sort of reminded now why I had a `PredicateAtom` in some PRs...
</code></pre></div>


</blockquote>



<a name="201869293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869293">(Jun 24 2020 at 16:16)</a>:</h4>
<p>(fn elaborate): I considered using something along the lines of <code>PredicateKind::ForAll(binder) =&gt; binder.map_bound(recurse),</code> here</p>



<a name="201869395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869395">(Jun 24 2020 at 16:16)</a>:</h4>
<p>I was reviewing my older branches</p>



<a name="201869426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869426">(Jun 24 2020 at 16:16)</a>:</h4>
<p>One of the things I see I was doing (but I can't remember if I halted for a good reason) was to have</p>



<a name="201869477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869477">(Jun 24 2020 at 16:17)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">enum</span> <span class="nc">Predicate</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">ForAll</span><span class="p">(</span><span class="n">Binder</span><span class="o">&lt;</span><span class="n">Predicate</span><span class="o">&gt;</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Atom</span><span class="p">(</span><span class="n">PredicateAtom</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">enum</span> <span class="nc">PredicateAtom</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="201869552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869552">(Jun 24 2020 at 16:18)</a>:</h4>
<p>but that was also kind of messy as we both ĥave to keep the currently implicit invariant of ForAll intact and change a lot places as this doesn't just return the elaborated predicates</p>



<a name="201869569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869569">(Jun 24 2020 at 16:18)</a>:</h4>
<p>which I think corresponds to the pattern we see a lot of wanting to "skip past" binders</p>



<a name="201869585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869585">(Jun 24 2020 at 16:18)</a>:</h4>
<p>almost always in these cases, we are looking for things that don't involve bound regions</p>



<a name="201869635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869635">(Jun 24 2020 at 16:18)</a>:</h4>
<p>I was thinking of going back to check and verify that, basically looking at all the sites that use the (very common) <code>ignore_quantifiers().skip_binders()</code> pattern</p>



<a name="201869672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869672">(Jun 24 2020 at 16:19)</a>:</h4>
<p>(as an aside, the name ignore quantifiers really misled me; it seems to do more the opposite, of introducing (possibly empty) forall quantifiers)</p>



<a name="201869774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869774">(Jun 24 2020 at 16:20)</a>:</h4>
<p>in any case, my point is, I could imagine this being cleaner if we had something like <code>fn atom(&amp;self) -&gt; Option&lt;&amp;PredicateAtom&lt;'tcx&gt;)</code></p>



<a name="201869832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869832">(Jun 24 2020 at 16:20)</a>:</h4>
<p>where it returns <code>None</code> if bound regions are involved</p>



<a name="201869845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869845">(Jun 24 2020 at 16:20)</a>:</h4>
<p>(though that may be too strict or some of the code)</p>



<a name="201869920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869920">(Jun 24 2020 at 16:21)</a>:</h4>
<p>an alternative would be something like <code>fn skip_binders_to_atom(&amp;self) -&gt; &amp;Atom</code> that recursively skips through binders, but anyway</p>



<a name="201869947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869947">(Jun 24 2020 at 16:21)</a>:</h4>
<p>I am not sure if I really think this is a good idea but it seems clear from the PR that there's a pattern here that we are ill-capturing</p>



<a name="201869993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201869993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201869993">(Jun 24 2020 at 16:21)</a>:</h4>
<p>I was also thinking about the fact that we lump everything into one <code>Predicate</code>, whereas chalk separates things a bit more</p>



<a name="201870046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201870046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201870046">(Jun 24 2020 at 16:22)</a>:</h4>
<p>e.g., it distinguishes <em>clauses</em> from <em>goals</em> and isolates out <em>where clauses</em></p>



<a name="201870111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201870111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201870111">(Jun 24 2020 at 16:22)</a>:</h4>
<p>so I wanted to try and think about things from that angle too; like, first off, maybe we should distinguish "where clauses" from other sorts of predicates (this would rule out those bits of code that have <code>bug!</code> for things a user could not have typed)</p>



<a name="201870138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201870138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201870138">(Jun 24 2020 at 16:22)</a>:</h4>
<p>but secondly I guess that part of the pattern today arises because users cannot type nested <code>for</code> binders and the like</p>



<a name="201870171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201870171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201870171">(Jun 24 2020 at 16:23)</a>:</h4>
<p>(although the elaboration code would most naturally make use of them)</p>



<a name="201870307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201870307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201870307">(Jun 24 2020 at 16:24)</a>:</h4>
<p>I'm not sure whether that is something we would just "never" want? I've gotten so used to thinking about chalk style goals with <code>for</code> and <code>if</code>...</p>



<a name="201870360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201870360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201870360">(Jun 24 2020 at 16:24)</a>:</h4>
<p>anywaY I guess the real question is whether that code that currently kind of matches can be rewritten in some other style that feels "just as natural"</p>



<a name="201872178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201872178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201872178">(Jun 24 2020 at 16:40)</a>:</h4>
<p><code>fn skip_binders_to_atom(&amp;self) -&gt; Atom</code> might work, though this still has the dangers that we have to remember to rebind in a lot of cases</p>



<a name="201872236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201872236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201872236">(Jun 24 2020 at 16:41)</a>:</h4>
<p>I think the main problem is that there is no nice way to go from <code>Binder(Enum)</code> to <code>Enum::Variant(Binder)</code></p>



<a name="201872413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201872413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201872413">(Jun 24 2020 at 16:42)</a>:</h4>
<p>It might be fairly clean to add a <code>BoundPredicate</code> enum which has the same definition as the old <code>PredicateKind</code> and which is returned by <code>ignore/unfold_quantifiers</code>.</p>



<a name="201872460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/201872460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#201872460">(Jun 24 2020 at 16:43)</a>:</h4>
<p>at which point we could just keep the current definition to begin with <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="202144026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202144026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202144026">(Jun 26 2020 at 21:20)</a>:</h4>
<p>Sigh, yeah, I mean the current definition <em>is</em> capturing something -- that we don't permit multiple levels of binder -- and the code was written kind of around that.</p>



<a name="202144034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202144034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202144034">(Jun 26 2020 at 21:20)</a>:</h4>
<p>So there are two questions</p>



<a name="202144041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202144041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202144041">(Jun 26 2020 at 21:21)</a>:</h4>
<ol>
<li>do we want that invariant?</li>
</ol>



<a name="202144098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202144098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202144098">(Jun 26 2020 at 21:21)</a>:</h4>
<ol start="2">
<li>is there another way to write the code that doesn't rely on that? I thik that would imply a more recursive structure</li>
</ol>



<a name="202144171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202144171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202144171">(Jun 26 2020 at 21:22)</a>:</h4>
<p>I guess the other question is why I was so motivated to remove the binder.</p>



<a name="202155683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202155683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202155683">(Jun 26 2020 at 23:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/202144041">said</a>:</p>
<blockquote>
<ol>
<li>do we want that invariant?</li>
</ol>
</blockquote>
<p>I think you are talking about "ForAll must bind something" here. I believe so, if we don't have that invariant we have to handle every usage of <code>PredicateKind</code> as if unused <code>ForAll</code> might exist. So afaict most things, which do not use <code>infcx.replace_bound_vars_with_placeholders</code>, now have to deal with <code>ForAll</code>. Which makes this kind of worse IMO.</p>



<a name="202155854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202155854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202155854">(Jun 26 2020 at 23:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/202144098">said</a>:</p>
<blockquote>
<ol start="2">
<li>is there another way to write the code that doesn't rely on that? I thik that would imply a more recursive structure</li>
</ol>
</blockquote>
<p>maybe <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> I might be able to get a better idea if I keep thinking about this for a while, but we tend to have a few different ways we use <code>Predicate</code>s</p>



<a name="202155885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202155885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202155885">(Jun 26 2020 at 23:39)</a>:</h4>
<ul>
<li>don't care about binders, e.g. they might only look at the <code>DefId</code> of a <code>PredicateKind::Trait</code><ul>
<li>I think these usecases will always get equally or slightly more cumbersome if we add <code>ForAll</code></li>
</ul>
</li>
</ul>



<a name="202155969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202155969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202155969">(Jun 26 2020 at 23:41)</a>:</h4>
<p>(deleted)</p>



<a name="202156154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202156154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202156154">(Jun 26 2020 at 23:44)</a>:</h4>
<ul>
<li>simply have to rebind the bound vars of the input, e.g. <code>elaborate</code><ul>
<li><code>PredicateKind::ForAll</code> probably doesn't help too much here as well (I think it at least doesn't make it worse)</li>
</ul>
</li>
</ul>



<a name="202156202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202156202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202156202">(Jun 26 2020 at 23:45)</a>:</h4>
<ul>
<li>actually deal with binding predicates in a different manner, e.g. <code>process_predicate</code> and some outlives bound stuff IIRC.<ul>
<li>I think these are cleaner when using <code>PredicateKind::ForAll</code></li>
</ul>
</li>
</ul>



<a name="202156471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202156471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202156471">(Jun 26 2020 at 23:51)</a>:</h4>
<p>While implementing <a href="https://github.com/rust-lang/rust/pull/73503">https://github.com/rust-lang/rust/pull/73503</a> it felt like I mostly had to deal with the first 2 types. There may be some additional places which are actually of type 3, but it still felt like we are mostly doing more work here</p>



<a name="202236603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202236603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202236603">(Jun 28 2020 at 13:25)</a>:</h4>
<blockquote>
<p>I think you are talking about "ForAll must bind something" here.</p>
</blockquote>
<p>or wait, you probably mean "that we don't permit multiple levels of binder"  <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> I think this depends on if there are situations where multiple levels of binders are useful when dealing with predicates</p>



<a name="202236734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202236734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202236734">(Jun 28 2020 at 13:29)</a>:</h4>
<p>looking at <code>for&lt;'a&gt; for&lt;'b&gt; T: Trait&lt;'a, 'b&gt;</code>, this should be identical to <code>for&lt;'a, 'b&gt; T: Trait&lt;'a, 'b&gt;</code>.</p>



<a name="202236812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202236812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202236812">(Jun 28 2020 at 13:31)</a>:</h4>
<p>So if there are no semantic differences between these two representations I think it's easier if we only have to deal with one of them.</p>



<a name="202369178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202369178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202369178">(Jun 29 2020 at 21:16)</a>:</h4>
<p>I'm not sure.</p>



<a name="202369202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202369202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202369202">(Jun 29 2020 at 21:17)</a>:</h4>
<p>Elaboration, for example, would be easier if we permitted nesting.</p>



<a name="202369211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202369211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202369211">(Jun 29 2020 at 21:17)</a>:</h4>
<p>And cleaner overall then it was.</p>



<a name="202369246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202369246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202369246">(Jun 29 2020 at 21:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/202155885">said</a>:</p>
<blockquote>
<ul>
<li>don't care about binders, e.g. they might only look at the <code>DefId</code> of a <code>PredicateKind::Trait</code><ul>
<li>I think these usecases will always get equally or slightly more cumbersome if we add <code>ForAll</code></li>
</ul>
</li>
</ul>
</blockquote>
<p>this is the case that I was kind of going after with the "atom" idea</p>



<a name="202369262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202369262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202369262">(Jun 29 2020 at 21:17)</a>:</h4>
<p>I agree that there is some inherent "tension" around skipping the binder and how visible to make it</p>



<a name="202369338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202369338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202369338">(Jun 29 2020 at 21:18)</a>:</h4>
<p>but I think that having <code>predicate.skip_binders()</code> which returns a <code>PredicateAtom</code> would be fairly clean</p>



<a name="202369441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202369441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202369441">(Jun 29 2020 at 21:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/202369211">said</a>:</p>
<blockquote>
<p>And cleaner overall then it was.</p>
</blockquote>
<p>but I guess there would be a canonicalization concern</p>



<a name="202372388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202372388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202372388">(Jun 29 2020 at 21:51)</a>:</h4>
<p><code>predicate.skip_binders() -&gt; PredicateAtom</code> seems both fairly explicit in what it's doing and still fairly short, I like it <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="202372671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202372671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202372671">(Jun 29 2020 at 21:54)</a>:</h4>
<blockquote>
<p>but I guess there would be a canonicalization concern</p>
</blockquote>
<p>yeah, didn't even consider that <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> so not having minimum required quantifiers is somewhat bad for caching</p>



<a name="202374338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202374338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202374338">(Jun 29 2020 at 22:12)</a>:</h4>
<p>What is the plan for <code>PredicateKind::Implies</code>? That was one of the reasons why this change is desirable IIUC</p>



<a name="202474697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202474697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202474697">(Jun 30 2020 at 18:15)</a>:</h4>
<p>Well, we basically just need to add it =) it would extend the <code>ParamEnv</code> with new clauses</p>



<a name="202474769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202474769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202474769">(Jun 30 2020 at 18:16)</a>:</h4>
<p>Overall, I still think we should do the change just because I think we should be aligning rustc with a general logical language</p>



<a name="202474825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202474825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202474825">(Jun 30 2020 at 18:16)</a>:</h4>
<p>However, I think the PR as is doesn't feel "right" to me, which suggests to me we ought to refine <code>Predicate</code> some more</p>



<a name="202474906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202474906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202474906">(Jun 30 2020 at 18:17)</a>:</h4>
<p>I think the <code>PredicateAtom</code> feels pretty plausible, I also suspect we may want to pull out a <code>WhereClause</code> from within that <code>Atom</code> that corresponds to things the <em>user</em> can write</p>



<a name="202474940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202474940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202474940">(Jun 30 2020 at 18:17)</a>:</h4>
<p>which in turn means that some parts of the code might just use <code>Binders&lt;WhereClause&gt;</code></p>



<a name="202475040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202475040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202475040">(Jun 30 2020 at 18:18)</a>:</h4>
<p>but I think we should look at that afterwards probably..</p>



<a name="202475050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202475050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202475050">(Jun 30 2020 at 18:18)</a>:</h4>
<p>... are you game to experiment with a <code>Atom</code>?</p>



<a name="202475060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202475060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202475060">(Jun 30 2020 at 18:18)</a>:</h4>
<p>also, i'm not sure where I came up with that name</p>



<a name="202475094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202475094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202475094">(Jun 30 2020 at 18:18)</a>:</h4>
<p>it's short, but I'm not sure how much it corresponds to the typical usage of the term "atom", which is more like "a single token" or something</p>



<a name="202475116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202475116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202475116">(Jun 30 2020 at 18:18)</a>:</h4>
<p>(something "indivisible")</p>



<a name="202475151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202475151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202475151">(Jun 30 2020 at 18:19)</a>:</h4>
<p>it's really a "first order" predicate I guess, or a "core" predicate?</p>



<a name="202478397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/202478397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#202478397">(Jun 30 2020 at 18:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/202475050">said</a>:</p>
<blockquote>
<p>... are you game to experiment with a <code>Atom</code>?</p>
</blockquote>
<p>jup, might take one or two weeks until I can get to this though</p>



<a name="203332192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/203332192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#203332192">(Jul 08 2020 at 22:37)</a>:</h4>
<p>updated it to use</p>
<div class="codehilite"><pre><span></span><code><span class="k">enum</span> <span class="nc">PredicateKind</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">ForAll</span><span class="p">(</span><span class="n">Binder</span><span class="o">&lt;</span><span class="n">Predicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;&gt;</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Atom</span><span class="p">(</span><span class="n">PredicateAtom</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>while there is still one issue with incorrect bound vars I think it is far enough to make the decision if this change is worth it (at least in terms of readability)</p>



<a name="203332468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/203332468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#203332468">(Jul 08 2020 at 22:41)</a>:</h4>
<p>I personally think most situations are more readable now, except <code>FulfillProcessor::process_obligation</code>, which can probably also be cleaned up.</p>



<a name="203332939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/203332939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#203332939">(Jul 08 2020 at 22:46)</a>:</h4>
<p>on multiple foralls:</p>
<blockquote>
<p>but I guess there would be a canonicalization concern</p>
</blockquote>
<p>One thing to consider is if we want to change <code>ForAll</code> to <code>ForAll(Binder&lt;PredicateAtom&lt;'tcx&gt;)</code>, which would encode the single forall depth as part of the type system, which seems fairly nice to me</p>



<a name="203333196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/203333196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#203333196">(Jul 08 2020 at 22:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> feel free to look at <a href="https://github.com/rust-lang/rust/pull/73503">https://github.com/rust-lang/rust/pull/73503</a> for a first impression on the new impl</p>



<a name="204256704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204256704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204256704">(Jul 17 2020 at 20:43)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> cool!</p>



<a name="204261205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204261205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204261205">(Jul 17 2020 at 21:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/203332939">said</a>:</p>
<blockquote>
<p>One thing to consider is if we want to change <code>ForAll</code> to <code>ForAll(Binder&lt;PredicateAtom&lt;'tcx&gt;)</code>, which would encode the single forall depth as part of the type system, which seems fairly nice to me</p>
</blockquote>
<p>I think we should probably do this so long as we are taking advantage of, or enforcing, this invariant. The main reason I can see <em>not</em> to do it would be to give ourselves the freedom to implement one or two things in a slightly more natural way.</p>



<a name="204261229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204261229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204261229">(Jul 17 2020 at 21:24)</a>:</h4>
<p>But as we said, it opens up some new problems...</p>



<a name="204261275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204261275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204261275">(Jul 17 2020 at 21:24)</a>:</h4>
<p>Reading the diff, so far, this seems a <strong>lot</strong> better, curious to get your opinion though</p>



<a name="204543448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204543448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204543448">(Jul 21 2020 at 12:56)</a>:</h4>
<p>So we currently use <code>Binder&lt;PredicateAtom&gt;</code> in <code>ForAll</code> and I tried to respond/implement all a reviews for now.</p>
<p>I also think this at least isn't worse than the previous state and considering that we can now more easily decouple higher ranked bounds during trait resolution this PR should make future changes easier.</p>



<a name="204543676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204543676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204543676">(Jul 21 2020 at 12:58)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> if you are also satisfied with this approach, I will look through this PR myself and do some more cleanup. After this it should be ready for a final review + merge</p>



<a name="204558061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204558061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204558061">(Jul 21 2020 at 14:58)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> I was feeling satisfied. I am confident that we can go from here to further simplifications, though I think the PR itself is kind of 'neutral' in its effects (not cleaner or less clean per se)</p>



<a name="204573030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204573030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204573030">(Jul 21 2020 at 16:53)</a>:</h4>
<p>nit: we currently have <code>Predicate::skip_binders</code> which can at most skip one binder. Should we rename this to <code>skip_binder</code>, even if it has the same name as <code>Binder::skip_binder</code>?</p>



<a name="204577550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204577550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204577550">(Jul 21 2020 at 17:30)</a>:</h4>
<p>nit: I original renamed <code>Obligation&lt;'tcx, ty::PolyTraitPredicate&lt;'tcx&gt;&gt;</code>  from <code>TraitPredicate</code> to <code>PolyTraitObligation</code> and added <code>Obligation&lt;'tcx, ty::TraitPredicate&lt;'tcx&gt;&gt;</code> as <code>TraitObligation</code>.</p>
<p>Considering that we never actually use <code>TraitObligation</code>, it might be better to revert that change</p>



<a name="204579728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204579728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204579728">(Jul 21 2020 at 17:49)</a>:</h4>
<p><a href="/user_uploads/4715/CK7nOdmziWN2kNt5Jopl2pbf/Screenshot-from-2020-07-21-19-47-35.png">end</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/CK7nOdmziWN2kNt5Jopl2pbf/Screenshot-from-2020-07-21-19-47-35.png" title="end"><img src="/user_uploads/4715/CK7nOdmziWN2kNt5Jopl2pbf/Screenshot-from-2020-07-21-19-47-35.png"></a></div>



<a name="204595923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204595923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204595923">(Jul 21 2020 at 19:59)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> maybe <code>skip_forall</code>?</p>



<a name="204595942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204595942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204595942">(Jul 21 2020 at 19:59)</a>:</h4>
<p>or <code>skip_forall_binders</code></p>



<a name="204595947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204595947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204595947">(Jul 21 2020 at 19:59)</a>:</h4>
<p>something like that?</p>



<a name="204595960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204595960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204595960">(Jul 21 2020 at 19:59)</a>:</h4>
<p>technically, plural is perhaps appropriate since it may skip zero binders</p>



<a name="204712186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204712186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204712186">(Jul 22 2020 at 19:34)</a>:</h4>
<p>Will we ever be able to skip a different binder for predicates?</p>



<a name="204712321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204712321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204712321">(Jul 22 2020 at 19:35)</a>:</h4>
<p>i.e.<br>
<code>PredicateKind::Implies</code> will probably be defined as <code>Implies(Predicate&lt;'tcx&gt;, Predicate&lt;'tcx&gt;)</code> so I don't know how skip binder makes sense here</p>



<a name="204712405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204712405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204712405">(Jul 22 2020 at 19:36)</a>:</h4>
<p>And merging <code>ExistentialPredicate</code>s with forall doesn't seem too desirable from what I can tell</p>



<a name="204712472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/204712472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#204712472">(Jul 22 2020 at 19:36)</a>:</h4>
<p>in which case <code>skip_forall</code> looks like a good idea</p>



<a name="205148866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205148866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205148866">(Jul 27 2020 at 18:03)</a>:</h4>
<p>I think that <code>Implies</code> is an <code>Atom</code></p>



<a name="205148895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205148895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205148895">(Jul 27 2020 at 18:03)</a>:</h4>
<p>Well, that's not obvious</p>



<a name="205148912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205148912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205148912">(Jul 27 2020 at 18:03)</a>:</h4>
<p>anyway, <span class="user-mention" data-user-id="216206">@lcnr</span>, I'm not really claer on whether <a href="https://github.com/rust-lang/rust/issues/73503">#73503</a> is ready to merge?</p>



<a name="205148934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205148934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205148934">(Jul 27 2020 at 18:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP/near/204712186">said</a>:</p>
<blockquote>
<p>Will we ever be able to skip a different binder for predicates?</p>
</blockquote>
<p>I don't think so, to directly answer the question. <code>Implies</code> is not a binder, in any case.</p>



<a name="205148987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205148987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205148987">(Jul 27 2020 at 18:04)</a>:</h4>
<p>In particular I don't think Rust will ever have <code>exists&lt;T&gt; { ... }</code> goals</p>



<a name="205149017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205149017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205149017">(Jul 27 2020 at 18:04)</a>:</h4>
<p>But if we do, we'll deal with the name then :)</p>



<a name="205149188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205149188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205149188">(Jul 27 2020 at 18:06)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span> tbh I don't really care. I reverted the change to <code>TraitObligation</code>, so if you are fine with <code>skip_binders</code> I would just merge this as is</p>



<a name="205149218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205149218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205149218">(Jul 27 2020 at 18:06)</a>:</h4>
<p>OK, I don't care too much either.</p>



<a name="205149230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205149230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205149230">(Jul 27 2020 at 18:06)</a>:</h4>
<p>I just delegated the PR to you but it appears to need a rebase</p>



<a name="205162108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205162108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205162108">(Jul 27 2020 at 20:06)</a>:</h4>
<p>rebased and r+</p>



<a name="205207172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205207172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205207172">(Jul 28 2020 at 08:04)</a>:</h4>
<blockquote>
<p>Introduce implication predicates, which extend the <code>ParamEnv</code> with new predicates</p>
</blockquote>



<a name="205207288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205207288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205207288">(Jul 28 2020 at 08:06)</a>:</h4>
<p>The MCP has the example <code>forall&lt;T&gt; { if (T: Debug) { Vec&lt;T&gt;: Debug } }</code></p>



<a name="205207322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205207322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205207322">(Jul 28 2020 at 08:06)</a>:</h4>
<p>this should probably be modeled as <code>ForAll(Implies(Trait, Trait))</code></p>



<a name="205207340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205207340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205207340">(Jul 28 2020 at 08:07)</a>:</h4>
<p>or <code>Implies(Binder(Trait, Trait))</code></p>



<a name="205207362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205207362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205207362">(Jul 28 2020 at 08:07)</a>:</h4>
<p>From what I can tell <code>ForAll(Implies(Trait, Trait))</code> is better</p>



<a name="205207495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205207495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205207495">(Jul 28 2020 at 08:09)</a>:</h4>
<p>So we probably want to define <code>Implies</code> as <code>PredicateAtom::Implies(Predicate&lt;'tcx&gt;, Predicate&lt;'tcx&gt;)</code></p>



<a name="205208165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205208165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205208165">(Jul 28 2020 at 08:18)</a>:</h4>
<p>I still don't know what we want to use implies for <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> it seems like implies is fairly similar to what <code>elaborate</code> is doing rn.</p>



<a name="205208196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205208196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205208196">(Jul 28 2020 at 08:18)</a>:</h4>
<p>From what I can tell the goal is to replace elaborate with something like <a href="https://rust-lang.github.io/chalk/book/clauses/implied_bounds.html?highlight=IMplies#computing-implied-bounds-with-fromenv">https://rust-lang.github.io/chalk/book/clauses/implied_bounds.html?highlight=IMplies#computing-implied-bounds-with-fromenv</a></p>



<a name="205620172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205620172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205620172">(Jul 31 2020 at 17:49)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> I think it would be <code>ForAll(Implies(...))</code>, i.e., we would add a <code>Implies</code></p>



<a name="205620189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205620189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205620189">(Jul 31 2020 at 17:49)</a>:</h4>
<p>it does't really have much to do with elaboration</p>



<a name="205620198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205620198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205620198">(Jul 31 2020 at 17:49)</a>:</h4>
<p>rather, it lets you introduce <em>where clauses</em></p>



<a name="205620312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205620312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205620312">(Jul 31 2020 at 17:50)</a>:</h4>
<p>the idea is that we would want to be able to add 'foralls' to talk about GATs and things</p>



<a name="205620350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactoring%20rustc%20predicates%2C%20a%20MCP/near/205620350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactoring.20rustc.20predicates.2C.20a.20MCP.html#205620350">(Jul 31 2020 at 17:50)</a>:</h4>
<p>we don't really have a suitable surface syntax for this in Rust though</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>